Beispiel #1
0
        public ActionResult RemoveFromCart(int id)
        {
            ProductVM vm = cart.GetShoppingCart().Find(x => x.Product.ID == id);

            cart.Remove(vm);
            return(Redirect(Request.UrlReferrer.ToString()));
        }
Beispiel #2
0
 protected override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     cart = new ProductCart(HttpContext, "ShoppingCart");
     ViewBag.AmountOfPrpductsInCart = cart.GetShoppingCart().Count;
     ViewBag.ShoppingCartTotal      = cart.Total;
     base.OnActionExecuting(filterContext);
 }
        public ActionResult Cart()
        {
            List <List <ProductVM> > shoppingCartList = new List <List <ProductVM> >();

            foreach (List <Product> productLine in cart.GetShoppingCart())
            {
                List <ProductVM> lvm = new List <ProductVM>();
                foreach (Product product in productLine)
                {
                    ProductVM vm = new ProductVM();
                    vm.Product  = product;
                    vm.Category = categoryFactory.Get(product.CategoryID);
                    vm.Images   = imageFactory.GetBy("ProductID", product.ID);
                    lvm.Add(vm);
                }
                shoppingCartList.Add(lvm);
            }
            return(View(shoppingCartList));
        }