コード例 #1
0
        public IActionResult Add()
        {
            var model = new StaffAddModelHybrid {
                RoleList = EmployeeEnum.RoleList()
            };

            return(View(model));
        }
コード例 #2
0
        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"));
        }