public async Task <ActionResult> Post(Cupom cupom) { try { await _repository.Add(cupom); await _uow.Commit(); return(CreatedAtAction("Post", await Get(cupom.Id))); } catch (Exception ex) { await _uow.Rollback(); return(BadRequest(ex)); } }
protected override Task Handle(CriarCupomCommand command, CancellationToken cancellationToken) { var cupom = new Cupom(command.CodigoCupom); return(_cupomRepository.Add(cupom)); }