示例#1
0
        private async Task CancelarPagamento(PedidoCanceladoIntegrationEvent message)
        {
            using var scope = _serviceProvider.CreateScope();
            var pagamentoService = scope.ServiceProvider.GetRequiredService <IPagamentoService>();
            var response         = await pagamentoService.CancelarPagamento(message.PedidoId);

            if (!response.ValidationResult.IsValid)
            {
                throw new DomainException($"Falha ao cancelar pagamento do pedido {message.PedidoId}");
            }
        }
示例#2
0
        private async Task CancelarPedido(PedidoCanceladoIntegrationEvent message)
        {
            using var scope = _serviceProvider.CreateScope();
            var pedidoRepository = scope.ServiceProvider.GetRequiredService <IPedidoRepository>();
            var pedido           = await pedidoRepository.ObterPorId(message.PedidoId);

            pedido.CancelarPedido();
            pedidoRepository.Atualizar(pedido);

            if (!await pedidoRepository.UnitOfWork.Commit())
            {
                throw new DomainException($"Problema ao finalizar o pedido {message.PedidoId}");
            }
        }
示例#3
0
 public async void CancelarPedidoSemEstoque(PedidoAutorizadoIntegrationEvent message)
 {
     var pedidoCancelado = new PedidoCanceladoIntegrationEvent(message.ClienteId, message.PedidoId);
     await _bus.PublishAsync(pedidoCancelado);
 }