Esempio n. 1
0
        public ActionResult Cart(string AddProduct)
        {
            List <AlbumInfo> ShoppingBag; // reference to null

            if (Session["Cart"] == null)  // the cart is empty!
            {
                Session.Add("Cart", new List <AlbumInfo>());
                ShoppingBag = new List <AlbumInfo>();
            }
            else// user has items in the cart, so go and retrive it!
            {
                ShoppingBag = (List <AlbumInfo>)Session["Cart"];
            }
            ///////////////////////////
            vmrdataEntities DB = new vmrdataEntities();


            AlbumInfo Option = DB.AlbumInfoes.Find(AddProduct);

            ShoppingBag.Add(Option);
            Session["Cart"] = ShoppingBag;// save changes you made to your cart!

            ViewBag.PList = ShoppingBag;

            //
            double sum = 0;

            for (int i = 0; i < ShoppingBag.Count; i++)
            {
                sum = sum + ShoppingBag[i].Price;
            }

            ViewBag.Sum = sum;
            return(View("Checkout"));
        }
Esempio n. 2
0
        public ActionResult AddtoCart(string Souvenir)
        {
            List <Souvenir> ShoppingBag; // reference to null

            if (Session["Cart"] == null) // the cart is empty!
            {
                Session.Add("Cart", new List <Souvenir>());

                ShoppingBag = new List <Souvenir>();
            }

            else// user has items in the cart, so go and retrive it!
            {
                ShoppingBag = (List <Souvenir>)Session["Cart"];
            }
            ///////////////////////////
            maedbEntities2 ItemList = new maedbEntities2();


            Souvenir Option = ItemList.Souvenirs.Find(Souvenir);

            ShoppingBag.Add(Option);

            Session["Cart"] = ShoppingBag;// save changes you made to your cart!

            ViewBag.Cart = ShoppingBag;

            maedbEntities2  NewList     = new maedbEntities2();
            List <Souvenir> AllProducts = NewList.Souvenirs.ToList();

            ViewBag.PList = AllProducts;



            return(RedirectToAction("Product"));
        }