public ActionResult UpdateEmployee(int?id) { var companies = GetCompaniesNames(); var employee = _service.EmployeeService.GetItem(id) ?? new EmployeeDTO() { Company = new CompanyDTO() }; var employeeVM = new EmployeeVMUpdate() { Name = employee.Name, Surname = employee.Surname, Patronymic = employee.Patronymic, EmploymentDate = employee.EmploymentDate, Position = employee.Position, Companies = companies }; return(View(employeeVM)); }
public RedirectToRouteResult UpdateEmployee(EmployeeVMUpdate employeeVM) { var employeeDTO = new EmployeeDTO() { Id = employeeVM.Id, Name = employeeVM.Name, Surname = employeeVM.Surname, Patronymic = employeeVM.Patronymic, EmploymentDate = employeeVM.EmploymentDate ?? DateTime.Now, Position = employeeVM.Position, Company = new CompanyDTO() { CompanyName = employeeVM.Companies[0] } }; _service.EmployeeService.Update(employeeDTO); return(RedirectToAction("Index")); }