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); }
public async Task <IActionResult> Create([FromBody] PriceCreateCommand priceCreate) => HandleCommand(await _mediator.Send(priceCreate));