Usually you encapsulate this in teams that aggregates in your contract.
For example, using Order Aggregation, you can add OrderLines using data received from your GUI.
// This is the Order Aggregate Root public class Order { private readonly int id; private readonly Customer customer; // Customer is another Aggregate private readonly IList<OrderLine> orderLines; private readonly IOrderLineFactory orderLineFactory; public Order(int id, Customer customer, IOrderLineFactory orderLineFactory) { this.id = id; this.customer = customer; this.orderLines = new List<OrderLine>(); this.orderLineFactory = orderLineFactory; } public void AddOrderLine(Item item, int quantity) { OrderLine orderLine = orderLineFactory.Create(this, item, quantity); orderLines.Add(orderLine); } }
Michael hart
source share