public async Task <IActionResult> Post([FromBody] EmployeeModel model) { return(await ExecuteHandledOperationAsync <IActionResult>(async() => { if (model == null) { return BadRequest("Employee is null."); } var employee = Mapper.Map <Acme.WebCore.Models.EmployeeModel, Acme.Core.Domain.Employee>(model); await _manager.AddAsync(employee); await UnitOfWork.SaveAsync(); return CreatedAtRoute( "Get", new { Id = employee.EmployeeId }, employee); })); }
public IActionResult Add(AddEmployeeViewModel dto) { if (!ModelState.IsValid) { dto.Positions = dbManager.GetAll <Position>().ToList(); dbManager.Commit(); return(View("Add", dto)); } var result = employeeManager.AddAsync(dto); //string message = result ? "Объект сохранён" : "Не удалось"; dbManager.Commit(); string message = result != null ? $"Объект сохранён" : "Не удалось"; var res = new ResultViewModel(message, message, $"/staff", "Назад"); return(View("Result", res)); }