Exemplo n.º 1
0
 public ActionResult AddNew()
 {
     CreateEmployeeViewModel employeeListViewModel = new CreateEmployeeViewModel();
     employeeListViewModel.UserName = User.Identity.Name;
     return View("CreateEmployee", employeeListViewModel);
 }
Exemplo n.º 2
0
 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;
                 }
                 vm.UserName = User.Identity.Name;
                 return View("CreateEmployee", vm);
             }
         case "Cancel":
             return RedirectToAction("Index");
     }
     return new EmptyResult();
 }