예제 #1
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();
                }
            }
        }