public ActionResult EditEmployee(int id) { AdminEditEmployeeVM VM = new AdminEditEmployeeVM(); var repo = new EmployeeRepositoryADO(); var currentEmployee = repo.ReadByEmployeeId(id); VM.Form.EmployeeId = currentEmployee.EmployeeId; VM.Form.LastName = currentEmployee.LastName; VM.Form.FirstName = currentEmployee.FirstName; VM.Form.Email = currentEmployee.Email; VM.Form.Role = currentEmployee.Role; return(View(VM)); }
public ActionResult EditEmployee(AdminEditUserCM form) { if (ModelState.IsValid) { var repo = new EmployeeRepositoryADO(); var employee = repo.ReadByEmployeeId(form.EmployeeId); employee.FirstName = form.FirstName; employee.LastName = form.LastName; employee.Email = form.Email; employee.Role = form.Role; repo.UpdateEmployee(employee); return(RedirectToAction("Vehicle")); } else { AdminEditEmployeeVM VM = new AdminEditEmployeeVM(); var repo = new EmployeeRepositoryADO(); VM.Form = form; return(View(VM)); } }