示例#1
0
        // GET: Cart
        public ActionResult ViewCart(int Id, string sessionId, int?productId, int?quantity)
        {
            //send to view
            ViewData["sessionId"] = sessionId;
            ViewData["Id"]        = Id;

            //second view cart (after user edit cart) there is a productId
            if (productId != null)
            {
                UpdateQuantityPerProductId(sessionId, (int)productId, (int)quantity);
            }

            //Retreieve OrderSummary and CartProducts and send to view
            List <Order> OrderSummary = (List <Order>)Session[sessionId + "_Orders"];
            List <Order> cartProducts = ProductsData.GetProductsByProductId(OrderSummary);

            ViewData["cartProducts"] = cartProducts;
            ViewData["OrderSummary"] = OrderSummary;

            //to calculate total price
            RefreshPrice(cartProducts);

            return(View());
        }