Exemplo n.º 1
0
        public void AddToCart(Product product, Store store, int quantity)
        {
            ProductStock productStock = CustomerPurchaseItems.FirstOrDefault(x => x.ProductID == product.ProductID &&
                x.StoreID == store.StoreID);

            if (productStock == null)
            {
                CustomerPurchaseItems.Add(new ProductStock
                {
                    ProductID = product.ProductID,
                    Product = product,
                    StoreID = store.StoreID,
                    Store = store,
                    Quantity = quantity,

                });

            }
            else
            {
                productStock.Quantity = quantity;
            }
        }
Exemplo n.º 2
0
 public void RemoveFromCart(Product product, int index)
 {
     var item = CustomerPurchaseItems.First(x => x.ProductID == index);
     CustomerPurchaseItems.Remove(item);
 }
Exemplo n.º 3
0
 public void ChangeQuantity(Product product, int index, int quantity)
 {
     var item = CustomerPurchaseItems.First(x => x.ProductID == index);
     item.Quantity = quantity;
 }