public static void AddCartItem(int ProductID, int Amount, string DiscountCode = "")
        {
            Product CurrentProduct = GetProduct(ProductID);
            CartItem NewCartItem = new CartItem(ProductID, CurrentProduct.UnitPrice, Amount);
            CurrentCart.AddToCart(NewCartItem);

            DB.AddCartItem(CurrentUser.CustomerID, ProductID, CurrentProduct.UnitPrice, Amount, DiscountCode);
            //DB.addNewOrder("ALFKI", DateTime.Now, 1, DateTime.Now, DateTime.Now, 1, 24.24);
        }
 public void RemoveItem(CartItem item)
 {
     cart.Remove(item);
 }
 public void AddToCart(CartItem item)
 {
     cart.Add(item);
 }
 //Gets cart items for a customer from the DB
 public static List<CartItem> LoadShoppingCart(string CustomerID)
 {
     CurrentCart = new ShoppingCart(CustomerID);
     DataTable Items = DB.GetCart(CustomerID);
     foreach (DataRow item in Items.Rows)
     {
         CartItem tmp = new CartItem((int)item["ProductID"], (decimal)item["UnitPrice"], (int)(short)item["Quantity"]);
         CurrentCart.AddToCart(tmp);
     }
     return CurrentCart.Cart;
 }
Exemple #5
0
 void updateShoppingCart(CartItem product)
 {
     ShoppingCart shopCart = Session["shoppingCart"] != null ? (ShoppingCart)Session["shoppingCart"] : null;
     bool productNotFound = true;
     if(product.Quantity <= short.MaxValue) {
         if(shopCart != null) {
             foreach(CartItem p in shopCart.Cart) {
                 if(product.ProductID == p.ProductID) {
                     productNotFound = false;
                     BusinessLayer.UpdateCartItem((string)Session["CusID"], product.ProductID, product.Quantity);
                 }
             }
             if(productNotFound)
                 BusinessLayer.AddCartItem(product.ProductID, product.Quantity, "");
             Session["shoppingCart"] = BusinessLayer.CurrentCart;
             updateShoppingCartList();
         }
     }
 }