public ActionResult AddEmployee(EmployeeRequest request) { if (!ModelState.IsValid) { return(CustomResponse(ModelState)); } try { var employee = _mapper.Map <EmployeeRequest, Employee>(request); if (employee.Notifications.Any()) { return(CustomResponse(employee.Notifications)); } var result = _employeeAppService.AddEmployee(employee); var employeeResponse = _mapper.Map <Employee, EmployeeResponse>(result); return(CustomResponse(employeeResponse)); } catch (Exception ex) { MessageException(); return(CustomExceptionResponse()); } }
public async Task <IActionResult> Add([FromBody] EmployeeViewModel EmployeeViewModel) { var data = await _employeeAppService.AddEmployee(EmployeeViewModel); if (data.ValidationResult.IsValid) { return(Ok(data)); } return(BadRequest(data)); }
public async Task <IActionResult> CreateAsync([FromBody] AddEmployeeCommand command) { var response = await _employeeAppService.AddEmployee(command); return(CreateResponseOnPost(response, RouteResponseConsts.Employee)); }