public async Task <Result> Handle(NewPriceType command, CancellationToken cancellationToken) { var titleResult = Title.New(command.Title); if (titleResult.Failed) { return(titleResult); } var title = titleResult.Value; var priceTypeResult = PriceType.New(title, _policy); if (priceTypeResult.Failed) { return(priceTypeResult); } var priceType = priceTypeResult.Value; await _repository.AddAsync(priceType, cancellationToken); await _uow.SaveChangesAsync(cancellationToken); await _bus.PublishAsync(priceType); return(Ok()); }
public async Task <IActionResult> Post(NewPriceType command) { var result = await _mediator.Send(command); if (result.Failed) { return(BadRequest(result.Message)); } return(Ok()); }