Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 public static ShoppingCartItem Create(int quantity, Product product)
 {
     var item = new ShoppingCartItem {Quantity = quantity, Product = product};
     return item;
 }
Exemplo n.º 3
0
 public static OrderItem CreateNewForOrder(Order order, int quantity, Product product)
 {
     var item = new OrderItem { Quantity = quantity, Product = product, Order = order };
     return item;
 }
Exemplo n.º 4
0
 public bool Delete(Product aggregate)
 {
     throw new System.NotImplementedException();
 }