From 9f80be5ed954f73e66d27180b0acea45baf4ee1f Mon Sep 17 00:00:00 2001 From: CESARDL Date: Tue, 7 Feb 2017 16:59:09 -0800 Subject: [PATCH] Added DDD comments about the CreateOrderCommandHandler --- .../Commands/CreateOrderCommandHandler.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs index 483ab9be9..ded49ab06 100644 --- a/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs @@ -12,6 +12,7 @@ private readonly IBuyerRepository _buyerRepository; private readonly IOrderRepository _orderRepository; + // Using DI to inject infrastructure persistence Repositories public CreateOrderCommandHandler(IBuyerRepository buyerRepository, IOrderRepository orderRepository) { if (buyerRepository == null) @@ -29,8 +30,11 @@ } public async Task Handle(CreateOrderCommand message) - { - //find buyer/payment or add a new one buyer/payment + { + // Add/Update the Buyer AggregateRoot + // DDD patterns comment: Add child entities and value-objects through the Order Aggregate-Root + // methods and constructor so validations, invariants and business logic + // make sure that consistency is preserved across the whole aggregate var buyer = await _buyerRepository.FindAsync(message.BuyerFullName); @@ -51,7 +55,10 @@ await _buyerRepository.UnitOfWork .SaveChangesAsync(); - //create order for buyer and payment method + // Create the Order AggregateRoot + // DDD patterns comment: Add child entities and value-objects through the Order Aggregate-Root + // methods and constructor so validations, invariants and business logic + // make sure that consistency is preserved across the whole aggregate var order = new Order(buyer.Id, payment.Id, new Address(message.Street, message.City, message.State, message.Country, message.ZipCode));