Ejemplo n.º 1
0
        public ActionResult DeleteItem(string name)
        {
            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"];
            }
            ///////////////////////////



            Souvenir Option = ShoppingBag.Find(x => x.Souvenirname == name);

            ShoppingBag.Remove(Option);

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


            ViewBag.Cart = ShoppingBag;



            return(View("Cart"));
        }
Ejemplo n.º 2
0
        public ActionResult Delete(string Album)
        {
            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"];
            }


            ShoppingBag.Remove(ShoppingBag.Find(x => x.Album == Album));


            ViewBag.PList = ShoppingBag;
            List <Double> prices = new List <Double>();
            //
            double sum   = 0;
            double price = 0;

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


            ViewBag.Price = price;
            ViewBag.Sum   = sum;
            return(View("Checkout"));
        }