コード例 #1
0
        public static ShoppingCartLogic GetCart(HttpContextBase context)
        {
            var cart = new ShoppingCartLogic();

            cart.ShoppingCartId = cart.GetCartId(context);
            return(cart);
        }
コード例 #2
0
        public ActionResult RemoveFromCart(int id)
        {
            var cart = ShoppingCartLogic.GetCart(this.HttpContext);

            var shoppingCart = new ShoppingCartLogic();
            int productId = shoppingCart.GetCartItemProductId(id);
            var productService = new ProductLogic();
            Product productToRemove = productService.FindProduct(productId);

            int itemCount = cart.RemoveFromCart(id);

            var removeViewModel = new ShoppingCartRemoveVM
            {
                Message = Server.HtmlEncode(productToRemove.Name) +
                    " has been removed from your shopping cart.",
                CartCount = cart.GetCount(),
                CartSubTotal = cart.GetSubtotal(),
                CartSalesTax = cart.GetSalesTax(),
                CartTotal = cart.GetTotal(),
                ItemCount = itemCount,
                DeleteId = id,
            };

            return Json(removeViewModel);
        }
コード例 #3
0
 public static ShoppingCartLogic GetCart(HttpContextBase context)
 {
     var cart = new ShoppingCartLogic();
     cart.ShoppingCartId = cart.GetCartId(context);
     return cart;
 }