public ActionResult RemoveFromCart(int id) {
            // Remove the item from the cart
            var cart = ShoppingCart.GetCart(storeDB, 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);

            storeDB.SaveChanges();

            string removed = (itemCount>0) ? " 1 of " : string.Empty;

            // Display the confirmation message

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

            return Json(results);
        }
        public ActionResult RemoveFromCart(int id)
        {
            // Remove the item from the cart
            ShoppingCart cart = ShoppingCart.GetCart(_cartStoreService);

            // 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.º 3
0
        public async Task<ActionResult> RemoveFromCart(int id)
        {
            var cart = ShoppingCart.GetCart(_storeContext, this);

            var albumName = await _storeContext.Carts
                .Where(i => i.RecordId == id)
                .Select(i => i.Album.Title)
                .SingleOrDefaultAsync();

            var itemCount = await cart.RemoveFromCart(id);

            await _storeContext.SaveChangesAsync();

            var removed = (itemCount > 0) ? " 1 copy of " : string.Empty;

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

            return Json(results);
        }
        public ActionResult RemoveFromCart(int id)
        {
            // Remove the item from the cart
            ShoppingCart.Models.ShoppingCart shoppingCart = new ShoppingCart.Models.ShoppingCart();
            var cart = shoppingCart.GetCart(HttpContext.Session.SessionID);
            ShoppingCartContext storeDB = shoppingCart.getDB();

            // Get the name of the album to display confirmation
            string produdctTitle = storeDB.CartItems.Single(i => i.ProductID == id).Product.Title;

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

            // Display the confirmation message
            var results = new ShoppingCartRemoveViewModel
            {
                Message = Server.HtmlEncode(produdctTitle) +
                    " has been removed from your shopping cart.",
                CartTotal = shoppingCart.GetTotal(),
                CartCount = shoppingCart.GetCount(),
                ItemCount = itemCount,
                DeleteId = id
            };
            return Json(results);
        }
 public ActionResult RemoveFromCart(int id)
 {
     var cart = ShoppingCart.GetCart(this.HttpContext);
     string albumName = storeDB.Carts
         .Single(item => item.RecordId == id).Album.Title;
     int 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);
 }
        public ActionResult RemoveFromCart(int id)
        {
            // Remove the item from the cart
            var cart = 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. Note that for simplicity, we're
            // removing all rather than decrementing the count.
            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(),
                DeleteId = id
            };

            return Json(results);
        }
        public ActionResult RemoveFromCart(int id)
        {
            // Remove the item from the cart
            var cart = ShoppingCart.GetCart(HttpContext);

            // Get the name of the album to display confirmation
            var albumName = _cartAppService.Get(id).Album.Title;

            // Remove from cart
            var 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);
        }
        public ActionResult RemoveFromCart(int id)
        {
            // Remove the item from the cart
            var cart = ShoppingCart.GetCart(this.HttpContext);

            // Get the name of the album to display confirmation
            string albumName = (from cartItems in _session.Query<NHCart>()
                                where cartItems.Id == id
                                select cartItems.Album.Title).First<string>();
                //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.º 9
0
        public virtual ActionResult RemoveFromCart(int id)
        {
            //using (var scope = new System.Transactions.TransactionScope())
            //{
                // Remove the item from the cart
                var cart = 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);

                //scope.Complete();

                // 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);
            //}
        }