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());
            }
        }
Example #2
0
        public async Task <IActionResult> Add([FromBody] EmployeeViewModel EmployeeViewModel)
        {
            var data = await _employeeAppService.AddEmployee(EmployeeViewModel);

            if (data.ValidationResult.IsValid)
            {
                return(Ok(data));
            }
            return(BadRequest(data));
        }
Example #3
0
        public async Task <IActionResult> CreateAsync([FromBody] AddEmployeeCommand command)
        {
            var response = await _employeeAppService.AddEmployee(command);

            return(CreateResponseOnPost(response, RouteResponseConsts.Employee));
        }