Пример #1
0
        public IActionResult AddToCart([FromServices] CartService srv, int prdId)
        {
            var customerId = HttpContext.Session.GetInt32("customerId") ?? 0;

            if (customerId == 0)
            {
                AddToCartForSession(srv, prdId, 1);
            }
            else
            {
                ViewData["ItemCount"] = srv.AddProductsToCart(customerId, prdId, 1);
            }
            return(PartialView("_CartButton"));
        }
Пример #2
0
        public IActionResult AddToCartFromDetail([FromServices] CartService srv, int prdId, int quantity)
        {
            var customerId = HttpContext.Session.GetInt32("customerId") ?? 0;

            if (customerId == 0)
            {
                AddToCartForSession(srv, prdId, quantity);
            }
            else
            {
                srv.AddProductsToCart(customerId, prdId, quantity);
            }
            return(RedirectToAction("ViewCart", "Home"));
        }