Beispiel #1
0
        private async Task Handle(OrderPaymentRequestEvent orderPaymentRequest)
        {
            var paymentInfo = new PaymentInfo
            {
                CardNumber     = orderPaymentRequest.CardNumber,
                CardName       = orderPaymentRequest.CardName,
                CardExpiration = orderPaymentRequest.CardExpiration,
                Total          = orderPaymentRequest.Total
            };

            var paymentProcessStatus = await _mediator.Send(new OrderPaymentRequestCommand(paymentInfo));

            var orderPaymentUpdateMessage = new OrderPaymentUpdatedEvent(
                orderPaymentRequest.OrderId,
                paymentProcessStatus);

            try
            {
                // Отправляем результат платежа в шину.
                _eventBus.Publish(orderPaymentUpdateMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            _logger.LogDebug($"{orderPaymentRequest.OrderId}: ServiceBusListener received item.");
            await Task.Delay(20000);

            _logger.LogDebug($"{orderPaymentRequest.OrderId}:  ServiceBusListener processed item.");
        }
Beispiel #2
0
 public async Task Handle(OrderPaymentUpdatedEvent @event)
 {
     await _mediator.Send(new UpdateOrderPaymentStatusCommand(@event.OrderId, @event.PaymentSuccess));
 }