public ActionResult Cart(int id)
        {
            if (Session["cart"] == null)
            {
                List <Items> ItemsCart = new List <Items>();
                ItemsCart.Add(new Items(ShoppingCartObject.FindProduct(id), 1));
                Session["cart"] = ItemsCart;
            }
            else

            {
                List <Items> ItemsCart = (List <Items>)Session["cart"];
                int          ID        = IfExists(id);
                if (ID == -1)
                {
                    ItemsCart.Add(new Items(ShoppingCartObject.FindProduct(id), 1));
                }
                else
                {
                    ItemsCart[ID].Quantity++;
                }
                Session["cart"] = ItemsCart;
            }

            Logger.WriteToLog(DateTime.Now + " Product added to cart");
            return(View("Cart"));
        }
Пример #2
0
        // GET: Products/Details/5
        public ActionResult Details(int id)
        {
            Products product = productObject.FindProduct(id);

            return(View(product));
        }