Ejemplo n.º 1
0
        public ActionResult RemoveFromCart(int id)
        {
            // Remove the item from the cart
            var cart = Models.ShoppingCart.GetCart(this.HttpContext);

            // Get the name of the album to display confirmation
            string albumName = storeDB.Carts
                               .Single(item => item.RecordId == id).Album.Title;

            // Remove from cart
            int itemCount = cart.RemoveFromCart(id);

            // Display the confirmation message
            var results = new ShoppingCartRemoveViewModel
            {
                Message = Server.HtmlEncode(albumName) +
                          " has been removed from your shopping cart.",
                CartTotal = cart.GetTotal(),
                CartCount = cart.GetCount(),
                ItemCount = itemCount,
                DeleteId  = id
            };

            return(Json(results));
        }
Ejemplo n.º 2
0
        public ActionResult RemoveFromCart(int id)
        {
            var cart = Models.ShoppingCart.GetCart(HttpContext);

            var albumName = _dbContext.Carts
                            .Single(item => item.RecordId == id).Album.Title;

            var itemCount = cart.RemoveFromCart(id);

            var results = new ShoppingCartRemoveViewModel
            {
                Message = Server.HtmlEncode(albumName) +
                          " has been removed from your shopping cart.",
                CartTotal = cart.GetTotal(),
                CartCount = cart.GetCount(),
                ItemCount = itemCount,
                DeleteId  = id
            };

            return(Json(results));
        }