public Item(ItemsAddedEvent itemsAddedEvent) { if (itemsAddedEvent == null) { throw new ArgumentNullException(nameof(itemsAddedEvent)); } ProductName = itemsAddedEvent.ProductName; ProductSku = itemsAddedEvent.ProductSku; PricePerUnit = itemsAddedEvent.PricePerUnit; Quantity = itemsAddedEvent.Quantity; }
private void Handle(ItemsAddedEvent itemsAddedEvent) { var existingItem = FindExistingCartItem(itemsAddedEvent.ProductSku); if (existingItem == null) { items.Add(new Item(itemsAddedEvent)); } else { existingItem.Handle(itemsAddedEvent); } }
public void Handle(ItemsAddedEvent itemsAddedEvent) { if (itemsAddedEvent == null) { throw new ArgumentNullException(nameof(itemsAddedEvent)); } VerifyProductSkuMatchesInput(itemsAddedEvent.ProductSku); // We'll always just update the descriptor and unit price here. // This is an eventual consistency model. ProductName = itemsAddedEvent.ProductName; PricePerUnit = itemsAddedEvent.PricePerUnit; Quantity += itemsAddedEvent.Quantity; }