public IActionResult Add() { var model = new StaffAddModelHybrid { RoleList = EmployeeEnum.RoleList() }; return(View(model)); }
public async Task <IActionResult> Add(StaffAddModelHybrid 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.Create(employee); } return(RedirectToAction("Index")); }