public Task <CommandResult> Handle(FinalizarVendaCommand command, CancellationToken cancellationToken) { if (!command.IsValid()) { NotifyCommandErrors(command); return(Response()); } Venda venda = _vendaRepository.GetById(command.VendaId); venda.Finalizar(); if (NotifyModelErrors(venda.Errors)) { return(Response()); } else { _vendaRepository.Update(venda); } Commit(); return(Response()); }
public Task <CommandResult> Handle(FinalizarVendaCommand command, CancellationToken cancellationToken) { if (!command.IsValid()) { NotifyCommandErrors(command); return(Response()); } Venda venda = _vendaRepository.GetById(command.VendaId); venda.Finalizar(command.TipoVenda, command.QuantidadeParcelas, command.IntervaloVencimento, command.ValorEntrada); if (NotifyModelErrors(venda.Errors)) { return(Response()); } else { _vendaRepository.Update(venda); } if (Commit()) { _mediator.PublishEvent(new CheckedOutVendaEvent(venda)); } return(Response()); }