public async Task <ApiResponse> AddDepartment([FromBody] AddDepartmentCommand model)
        {
            var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            model.CreatedById = userId;
            model.CreatedDate = DateTime.UtcNow;
            return(await _mediator.Send(model));
        }
Beispiel #2
0
        public async Task <IActionResult> AddDepartment([FromBody] AddDepartmentCommand command)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var response = await _mediator.Send(command);

                    return(StatusCode(response.ResponseStatusCode, response.Value));
                }
                return(StatusCode(StatusCodes.Status400BadRequest));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex));
            }
        }
Beispiel #3
0
 public async Task <IActionResult> AddDepartment([FromBody] AddDepartmentCommand command)
 {
     return(Ok(await Mediator.Send(command)));
 }