コード例 #1
0
ファイル: VendaCommandHandler.cs プロジェクト: BOBO41/RCM
        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());
        }
コード例 #2
0
        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());
        }