예제 #1
0
        public ActionResult AddToCart(int id)
        {

            var addedItem = db.Produkter
                .Single(item => item.ProduktID == id);

            var cart = ShoppingCart.GetCart(this.HttpContext);

            cart.AddToCart(addedItem);

            // Display the confirmation message
            var results = new SCconfirmVM
            {
                Message = Server.HtmlEncode(addedItem.ProduktNamn) +
                    " har lagts till i din varukorg",
                CartTotal = cart.GetTotal() * 1.25,
                CartCount = cart.GetCount(),
                ItemCount = 1,
                DeleteId = id,
                totPris = addedItem.Pris * 1
                
            };
            return Json(results);
        }
예제 #2
0
        public ActionResult RemoveFromCart(int id)
        {
            
            
            var cart = ShoppingCart.GetCart(this.HttpContext);

            // Get the name of the Produkt to display confirmation
            var itemName = db.Produkter
                .Single(item => item.ProduktID == id);


            
            cart.RemoveFromCart(id);

            // Display the confirmation message
            var results = new SCconfirmVM
            {
                Message = "Alla " + Server.HtmlEncode(itemName.ProduktNamn) +
                    "'s har tagits bort from varukorgen.",
                CartTotal = cart.GetTotal() * 1.25,
                CartCount = cart.GetCount(),
                ItemCount = 0,
                DeleteId = id
                
            };
            return Json(results);
        }