public async Task<ActionResult> CreateStatusAysnc([FromBody] CreateStatusCommand request) { try { request.SetUser(User.GetUserId()); var response = await _mediator.Send(request); return Ok(response); } catch (Exception ex) { _logger.Error(ex, $"Operation failed into controller {Routes.Create_Status} with message: {ex.Message}"); return BadRequest(ex.Message); } }
public async Task CreateStatusAsync(CreateStatusCommand command) { if (command.Id == Guid.Empty) { throw new AggregateValidationException("Status Id is invalid."); } var status = await repository.GetAsync(command.Id); if (status != null) { throw new AggregateIllegalLogicException("Cannot create status with this Id. Status exists."); } await repository.CreateAsync(new StatusEntity(command.Id, command.Name)); }
public void Post(Option status) { var command = new CreateStatusCommand(); command.CreateStatus(status); }
public async Task <Unit> Post([FromBody] CreateStatusCommand request) { request.UserModel = await this.GetUserDetails("Ruru"); return(await Mediator.Send(request)); }