public async Task <IActionResult> CreateEmployeeAsync(CreateOrEditEmployeeRequest model) { var employee = EmployeeStaticMapper.MapFromModel(model); try { await _employeeRepository.CreateAsync(employee); } catch (Exception e) { return(BadRequest(e.Message)); } return(CreatedAtAction(nameof(GetEmployeeByIdAsync), new { id = employee.Id }, null)); }
public async Task <ActionResult> UpdateEmployeeAsync(Guid id, CreateOrEditEmployeeRequest model) { Employee employee = await _employeeRepository.GetByIdAsync(id); if (employee == null) { return(BadRequest()); } employee = EmployeeStaticMapper.MapFromModel(model, employee); try { await _employeeRepository.UpdateAsync(employee); } catch (Exception e) { return(BadRequest(e.Message)); } return(NoContent()); }