Esempio n. 1
0
        public ActionResult Cart()
        {
            if (SessionHelper.GetObjectFromJson <List <CartItem> >(HttpContext.Session, "cart") == null)
            {
                ViewBag.Message = "Your Cart Is Empty";
                this.cartCount  = 0;
            }
            else
            {
                var cart = SessionHelper.GetObjectFromJson <List <CartItem> >(HttpContext.Session, "cart");
                ViewBag.cart   = cart;
                this.cartCount = cart.Count;
                ViewBag.total  = cart.Sum(c => c.Product.Price * c.Quantity);
            }
            ViewModelService vms = new ViewModelService(_context, _httpContextAccessor);
            var viewmodel        = vms.GetProductViewModel();

            ViewBag.CartCount = this.cartCount;
            return(View(viewmodel));
        }
Esempio n. 2
0
        public IActionResult AddProduct()
        {
            var viewmodel = vms.GetProductViewModel();

            return(View(viewmodel));
        }