@@ -12,6 +12,7 @@ public class CreateOrderCommandHandler
1212 private readonly IBuyerRepository _buyerRepository ;
1313 private readonly IOrderRepository _orderRepository ;
1414
15+ // Using DI to inject infrastructure persistence Repositories
1516 public CreateOrderCommandHandler ( IBuyerRepository buyerRepository , IOrderRepository orderRepository )
1617 {
1718 if ( buyerRepository == null )
@@ -29,8 +30,11 @@ public CreateOrderCommandHandler(IBuyerRepository buyerRepository, IOrderReposit
2930 }
3031
3132 public async Task < bool > Handle ( CreateOrderCommand message )
32- {
33- //find buyer/payment or add a new one buyer/payment
33+ {
34+ // Add/Update the Buyer AggregateRoot
35+ // DDD patterns comment: Add child entities and value-objects through the Order Aggregate-Root
36+ // methods and constructor so validations, invariants and business logic
37+ // make sure that consistency is preserved across the whole aggregate
3438
3539 var buyer = await _buyerRepository . FindAsync ( message . BuyerFullName ) ;
3640
@@ -51,7 +55,10 @@ public async Task<bool> Handle(CreateOrderCommand message)
5155 await _buyerRepository . UnitOfWork
5256 . SaveChangesAsync ( ) ;
5357
54- //create order for buyer and payment method
58+ // Create the Order AggregateRoot
59+ // DDD patterns comment: Add child entities and value-objects through the Order Aggregate-Root
60+ // methods and constructor so validations, invariants and business logic
61+ // make sure that consistency is preserved across the whole aggregate
5562
5663 var order = new Order ( buyer . Id , payment . Id , new Address ( message . Street , message . City , message . State , message . Country , message . ZipCode ) ) ;
5764
0 commit comments