title: 'int' does not contain a definition for 'HasValue'?
body: <p>I am having trouble finding out what the error is with my code.  It says :</p>
  
  <blockquote>
    <p>'int' does not contain a definition for 'HasValue' and no extension method 'HasValue' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)    </p>
  </blockquote>
  
  <p>I checked my code and its correct but I can't find out where the error is coming from.  Here is the file </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using WebApplication1.Models;
  using WebApplication1.ViewModels;
  
  namespace WebApplication1.Controllers
  {
      public class EmployeeController : Controller
      {
          public string GetString()
          {
              return "Hello World is old now. It’s time for wassup bro ;)";
          }
  
          [NonAction]
          public string SimpleMethod()
          {
              return "Hi, I am not action method";
          }
  
          public ActionResult Index()
          {
              EmployeeListViewModel employeeListViewModel = new EmployeeListViewModel();
  
              EmployeeBusinessLayer empBal = new EmployeeBusinessLayer();
              List&lt;Employee&gt; employees = empBal.GetEmployees();
  
              List&lt;EmployeeViewModel&gt; empViewModels = new List&lt;EmployeeViewModel&gt;();
  
              foreach (Employee emp in employees)
              {
                  EmployeeViewModel empViewModel = new EmployeeViewModel();
                  empViewModel.EmployeeName = emp.FirstName + " " + emp.LastName;
                  empViewModel.Salary = emp.Salary.ToString("C");
  
                  if (emp.Salary &gt; 15000)
                  {
                      empViewModel.SalaryColor = "yellow";
                  }
                  else
                  {
                      empViewModel.SalaryColor = "green";
                  }
  
                  empViewModels.Add(empViewModel);
              }
  
              employeeListViewModel.Employees = empViewModels;
           //   employeeListViewModel.UserName = "Admin";
              return View("Index", employeeListViewModel);
          }
  
          public ActionResult AddNew()
          {
              return View("CreateEmployee", new CreateEmployeeViewModel());
          }
  
          public ActionResult SaveEmployee(Employee e, string BtnSubmit)
          {
              switch (BtnSubmit)
              {
                  case "Save Employee":
                      if (ModelState.IsValid)
                      {
                          EmployeeBusinessLayer empBal = new EmployeeBusinessLayer();
                          empBal.SaveEmployee(e);
                          return RedirectToAction("Index");
                      }
                      else
                      {
                          CreateEmployeeViewModel vm = new CreateEmployeeViewModel();
                          vm.FirstName = e.FirstName;
                          vm.LastName = e.LastName;
  
                          if (e.Salary.HasValue)
                          {
                              vm.Salary = e.Salary.ToString();
                          }
                          else
                          {
                              vm.Salary = ModelState["Salary"].Value.AttemptedValue;
                          }
  
                          return View("CreateEmployee", vm); // Day 4 Change - Passing e here
                      }
  
                  case "Cancel":
                      return RedirectToAction("Index");
              }
  
              return new EmptyResult();
          }
  
          public class MyEmployeeModelBinder : DefaultModelBinder
          {
              protected override object CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType)
              {
                  Employee e = new Employee();
                  e.FirstName = controllerContext.RequestContext.HttpContext.Request.Form["FName"];
                  e.LastName = controllerContext.RequestContext.HttpContext.Request.Form["LName"];
                  e.Salary = int.Parse(controllerContext.RequestContext.HttpContext.Request.Form["Salary"]);
                  return e;
              }
          }
      }
  }
  </code></pre>
  
  <p>It's the line </p>
  
  <pre><code>e.Salary.HasValue
  </code></pre>