コード例 #1
0
        public async Task <ActionResult <CondicaoPagamentoViewModel> > Adicionar(CondicaoPagamentoViewModel CondicaoPagamentoViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(CustomResponse(ModelState));
            }

            await _condicaoPagamentoService.Adicionar(_mapper.Map <CondicaoPagamento>(CondicaoPagamentoViewModel));

            return(CustomResponse(CondicaoPagamentoViewModel));
        }
コード例 #2
0
        public CondicaoPagamentoViewModel Atualizar(CondicaoPagamentoViewModel condicaoPagamento)
        {
            var condicaoPagamentoRetorno = Mapper.Map <CondicaoPagamentoViewModel>
                                               (_condicaoPagamentoService.Atualizar(Mapper.Map <CondicaoPagamento>(condicaoPagamento)));

            if (condicaoPagamentoRetorno.EhValido())
            {
                Commit();
            }

            return(condicaoPagamentoRetorno);
        }
コード例 #3
0
        public IActionResult Checkout(Guid id)
        {
            var venda = _vendaApplicationService.GetById(id);

            if (venda == null)
            {
                return(NotFound());
            }

            var parcelamento = new CondicaoPagamentoViewModel
            {
                Venda   = venda,
                VendaId = venda.Id,
            };

            return(View(parcelamento));
        }
コード例 #4
0
        public async Task <IActionResult> Checkout(Guid vendaId, CondicaoPagamentoViewModel condicaoPagamento)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(View(condicaoPagamento));
            }

            var commandResult = await _vendaApplicationService.FinalizarVenda(vendaId, condicaoPagamento);

            if (commandResult.Success)
            {
                NotifyCommandResultSuccess();
                return(RedirectToAction(nameof(Details), new { id = vendaId }));
            }
            else
            {
                NotifyCommandResultErrors(commandResult.Errors);
            }

            return(View(condicaoPagamento));
        }
コード例 #5
0
        public async Task <ActionResult <CondicaoPagamentoViewModel> > Atualizar(Guid id, CondicaoPagamentoViewModel CondicaoPagamentoViewModel)
        {
            if (id != CondicaoPagamentoViewModel.Id)
            {
                NotificarErro("O id informado não é o mesmo que foi passado na query");
                return(CustomResponse(CondicaoPagamentoViewModel));
            }

            if (!ModelState.IsValid)
            {
                return(CustomResponse(ModelState));
            }

            await _condicaoPagamentoService.Atualizar(_mapper.Map <CondicaoPagamento>(CondicaoPagamentoViewModel));

            return(CustomResponse(CondicaoPagamentoViewModel));
        }
コード例 #6
0
 public Task <CommandResult> FinalizarVenda(Guid vendaId, CondicaoPagamentoViewModel viewModel)
 {
     return(_mediator.SendCommand(new FinalizarVendaCommand(vendaId, viewModel.TipoVenda, viewModel.QuantidadeParcelas, viewModel.IntervaloVencimento, viewModel.ValorEntrada)));
 }