public ActionResult Edit(int id) { Employee empl = EmplRepoStub.ReadEmployee(id); var model = new EditEmplVM { EmployeeId = empl.Id, FirstName = empl.FirstName, LastName = empl.LastName, DeptId = empl.DepartmentId, PhoneNum = empl.PhoneNum, Departments = GetDepartmentsSelectListItems() }; return(View(model)); }
public ActionResult Edit(EditEmplVM model) { if (!ModelState.IsValid) { model.Departments = GetDepartmentsSelectListItems(); return(View(model)); } Employee edit = new Employee { Id = model.EmployeeId, FirstName = model.FirstName, LastName = model.LastName, PhoneNum = model.PhoneNum, DepartmentId = model.DeptId }; EmplRepoStub.EditEmployee(edit); return(RedirectToAction("List")); }