Exemplo n.º 1
0
        public async Task <Option <Exception, Guid> > Handle(PriceCreateCommand request, CancellationToken cancellationToken)
        {
            var allReadIn = await _repository.GetByDateAsync(request.Initial);

            if (allReadIn.IsSuccess)
            {
                return(new DuplicateException("Já existe preço com periodo inicial informado"));
            }

            var createCallBack = await _repository.CreateAsync(Mapper.Map <PriceCreateCommand, Price>(request));

            if (createCallBack.IsFailure)
            {
                return(createCallBack.Failure);
            }

            return(createCallBack.Success.Id);
        }
Exemplo n.º 2
0
 public async Task <IActionResult> Create([FromBody] PriceCreateCommand priceCreate)
 => HandleCommand(await _mediator.Send(priceCreate));