public async Task <Result> Handle(CreatePriceTypeCommand 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());
        }
Beispiel #2
0
        public async Task <IActionResult> Create([FromBody] CreatePriceTypeCommand command)
        {
            var result = await _mediator.Send(command);

            if (result.Failed)
            {
                return(BadRequest(result.Message));
            }

            return(Ok());
        }