public ActionResult AddNew() { CreateEmployeeViewModel createEmployeeViewModel = new CreateEmployeeViewModel(); //createEmployeeViewModel.FooterData = new FooterViewModel(); //createEmployeeViewModel.FooterData.CompanyName = "Acme Inc."; //createEmployeeViewModel.FooterData.Year = DateTime.Now.Year.ToString(); //createEmployeeViewModel.UserName = User.Identity.Name; return View("CreateEmployee", 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 createEmployeeViewModel = new CreateEmployeeViewModel(); createEmployeeViewModel.FirstName = e.FirstName; createEmployeeViewModel.LastName = e.LastName; //createEmployeeViewModel.FooterData = new FooterViewModel(); //createEmployeeViewModel.FooterData.CompanyName = "Acme Inc."; //createEmployeeViewModel.FooterData.Year = DateTime.Now.Year.ToString(); //createEmployeeViewModel.UserName = User.Identity.Name; if (e.Salary.HasValue) { createEmployeeViewModel.Salary = e.Salary.ToString(); } else { createEmployeeViewModel.Salary = ModelState["Salary"].Value.AttemptedValue; } return View("CreateEmployee", createEmployeeViewModel); } case "Cancel": return RedirectToAction("Index"); } return new EmptyResult(); }