public void AddItem(Guid productId, int quantity) { var orderItem = OrderedItems.SingleOrDefault(o => o.ProductId == productId && o.OrderId == Id); if (orderItem == null) { orderItem = new OrderedItem() { ProductId = productId, OrderId = Id, Quantity = quantity } } ; else { orderItem.Quantity += quantity; } OrderedItems.Add(orderItem); }
public void PlaceOrder(OrderPlacedEvent items) { items.Items.ForEach(x => OrderedItems.Add(x)); }