@ -8,20 +8,20 @@ using System.Threading.Tasks;
namespace Ordering.API.Application.DomainEventHandlers
namespace Ordering.API.Application.DomainEventHandlers
{
{
public class OrderCrea tedDomainEventHandler : IAsyncNotificationHandler < OrderCrea tedDomainEvent >
public class OrderStar tedDomainEventHandler : IAsyncNotificationHandler < OrderStar tedDomainEvent >
{
{
private readonly ILoggerFactory _logger ;
private readonly ILoggerFactory _logger ;
private readonly IBuyerRepository < Buyer > _buyerRepository ;
private readonly IBuyerRepository < Buyer > _buyerRepository ;
private readonly IIdentityService _identityService ;
private readonly IIdentityService _identityService ;
public OrderCrea tedDomainEventHandler ( ILoggerFactory logger , IBuyerRepository < Buyer > buyerRepository , IIdentityService identityService )
public OrderStar tedDomainEventHandler ( ILoggerFactory logger , IBuyerRepository < Buyer > buyerRepository , IIdentityService identityService )
{
{
_buyerRepository = buyerRepository ? ? throw new ArgumentNullException ( nameof ( buyerRepository ) ) ;
_buyerRepository = buyerRepository ? ? throw new ArgumentNullException ( nameof ( buyerRepository ) ) ;
_identityService = identityService ? ? throw new ArgumentNullException ( nameof ( identityService ) ) ;
_identityService = identityService ? ? throw new ArgumentNullException ( nameof ( identityService ) ) ;
_logger = logger ? ? throw new ArgumentNullException ( nameof ( logger ) ) ;
_logger = logger ? ? throw new ArgumentNullException ( nameof ( logger ) ) ;
}
}
public async Task Handle ( OrderCrea tedDomainEvent orderNotification )
public async Task Handle ( OrderStar tedDomainEvent orderNotification )
{
{
var cardTypeId = orderNotification . CardTypeId ! = 0 ? orderNotification . CardTypeId : 1 ;
var cardTypeId = orderNotification . CardTypeId ! = 0 ? orderNotification . CardTypeId : 1 ;
@ -33,7 +33,7 @@ namespace Ordering.API.Application.DomainEventHandlers
buyer = new Buyer ( buyerGuid ) ;
buyer = new Buyer ( buyerGuid ) ;
}
}
var payment = buyer . AddPaymentMethod ( cardTypeId ,
var paymentMethod = buyer . VerifyOr AddPaymentMethod( cardTypeId ,
$"Payment Method on {DateTime.UtcNow}" ,
$"Payment Method on {DateTime.UtcNow}" ,
orderNotification . CardNumber ,
orderNotification . CardNumber ,
orderNotification . CardSecurityNumber ,
orderNotification . CardSecurityNumber ,
@ -46,7 +46,7 @@ namespace Ordering.API.Application.DomainEventHandlers
await _buyerRepository . UnitOfWork
await _buyerRepository . UnitOfWork
. SaveEntitiesAsync ( ) ;
. SaveEntitiesAsync ( ) ;
_logger . CreateLogger ( nameof ( OrderCrea tedDomainEventHandler ) ) . LogTrace ( $"A new payment method has been successfully added for orderId: {orderNotification.Order.Id}." ) ;
_logger . CreateLogger ( nameof ( OrderStar tedDomainEventHandler ) ) . LogTrace ( $"A new payment method has been successfully added for orderId: {orderNotification.Order.Id}." ) ;
}
}
}
}