|
@ -1,16 +1,15 @@ |
|
|
using MediatR; |
|
|
using MediatR; |
|
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate; |
|
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate; |
|
|
using Microsoft.Extensions.Logging; |
|
|
using Microsoft.Extensions.Logging; |
|
|
using Ordering.API.Application.IntegrationEvents; |
|
|
|
|
|
using Ordering.API.Application.IntegrationEvents.Events; |
|
|
|
|
|
using Ordering.Domain.Events; |
|
|
using Ordering.Domain.Events; |
|
|
using System; |
|
|
using System; |
|
|
|
|
|
using System.Threading; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
|
namespace Ordering.API.Application.DomainEventHandlers.BuyerAndPaymentMethodVerified |
|
|
namespace Ordering.API.Application.DomainEventHandlers.BuyerAndPaymentMethodVerified |
|
|
{ |
|
|
{ |
|
|
public class UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler |
|
|
public class UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler |
|
|
: IAsyncNotificationHandler<BuyerAndPaymentMethodVerifiedDomainEvent> |
|
|
|
|
|
|
|
|
: INotificationHandler<BuyerAndPaymentMethodVerifiedDomainEvent> |
|
|
{ |
|
|
{ |
|
|
private readonly IOrderRepository _orderRepository; |
|
|
private readonly IOrderRepository _orderRepository; |
|
|
private readonly ILoggerFactory _logger; |
|
|
private readonly ILoggerFactory _logger; |
|
@ -25,7 +24,7 @@ namespace Ordering.API.Application.DomainEventHandlers.BuyerAndPaymentMethodVeri |
|
|
// Domain Logic comment:
|
|
|
// Domain Logic comment:
|
|
|
// When the Buyer and Buyer's payment method have been created or verified that they existed,
|
|
|
// When the Buyer and Buyer's payment method have been created or verified that they existed,
|
|
|
// then we can update the original Order with the BuyerId and PaymentId (foreign keys)
|
|
|
// then we can update the original Order with the BuyerId and PaymentId (foreign keys)
|
|
|
public async Task Handle(BuyerAndPaymentMethodVerifiedDomainEvent buyerPaymentMethodVerifiedEvent) |
|
|
|
|
|
|
|
|
public async Task Handle(BuyerAndPaymentMethodVerifiedDomainEvent buyerPaymentMethodVerifiedEvent, CancellationToken cancellationToken) |
|
|
{ |
|
|
{ |
|
|
var orderToUpdate = await _orderRepository.GetAsync(buyerPaymentMethodVerifiedEvent.OrderId); |
|
|
var orderToUpdate = await _orderRepository.GetAsync(buyerPaymentMethodVerifiedEvent.OrderId); |
|
|
orderToUpdate.SetBuyerId(buyerPaymentMethodVerifiedEvent.Buyer.Id); |
|
|
orderToUpdate.SetBuyerId(buyerPaymentMethodVerifiedEvent.Buyer.Id); |
|
|