Beispiel #1
0
        // AJAX: /ShoppingCart/RemoveFromShoppingCart/
        public JsonResult RemoveFromShoppingCart(string name)
        {
            // Check if there's a cart for this session
            ShoppingCart shoppingCart = _shoppingCartService.GetShoppingCart(CookieFactory.GetShoppingCartCookie(Request, Response));

            if (shoppingCart != null)
            {
                bool success = _shoppingCartItemService.DeleteShoppingCartItemByName(name);
                _shoppingCartService.SaveShoppingCart();

                decimal total = _offerService.GetTotal(shoppingCart, _itemService.GetItems());

                return(Json(new { success = success, total = total }, JsonRequestBehavior.AllowGet));
            }

            return(Json(null, JsonRequestBehavior.AllowGet));
        }