public ShoppingCart AddItem(int quantity, Product product) { var existingItem = (from i in Items where i.Product.Id == product.Id select i).SingleOrDefault(); if (existingItem != null) { existingItem.Quantity++; return this; } // Create new item Items.Add(ShoppingCartItem.Create(quantity, product)); return this; }
public static ShoppingCartItem Create(int quantity, Product product) { var item = new ShoppingCartItem {Quantity = quantity, Product = product}; return item; }
public static OrderItem CreateNewForOrder(Order order, int quantity, Product product) { var item = new OrderItem { Quantity = quantity, Product = product, Order = order }; return item; }
public bool Delete(Product aggregate) { throw new System.NotImplementedException(); }