Beispiel #1
0
        public IActionResult AddToCart(int productId)
        {
            var productToBeAdded = _productService.GetById(productId);
            var cart             = _cartSessionService.GetCard();

            _cartService.AddToCart(cart, productToBeAdded);
            _cartSessionService.SetCard(cart);
            TempData.Add("message", String.Format("Your product,{0}, was succesfully added to the cart!", productToBeAdded.ProductName));
            return(RedirectToAction("Index", "Product"));
        }
        public ViewViewComponentResult Invoke()
        {
            var model = new CartSummaryViewModel()
            {
                Cart = _cartSessionService.GetCard()
            };

            return(View(model));
        }