public async Task <IActionResult> Edit(StaffEditModelHybrid model, [FromServices] IRepositoryHandler <Role> repoRole) { if (ModelState.IsValid) { var employee = mapper.Map <Employees>(model); employee.Role = await repoRole.GetFirstEntityAsync(r => r.Name == (EmployeeRole)model.Role); repositoryHandler.Update(employee); return(RedirectToAction("Detailed", "Staff", model.StaffId)); } return(RedirectToAction("Index")); }
public async Task <IActionResult> Edit(int?id) { if (id != null) { var result = await repositoryHandler.GetEntryByIDAsync(id.Value); var model = new StaffEditModelHybrid { StaffId = result.Id, ShortName = result.ShortName, FullName = result.FullName, Email = result.Email, Role = (int)result.Role.Name, RoleList = EmployeeEnum.RoleList((int)result.Role.Name) }; return(View(model)); } return(RedirectToAction("Index")); }