Пример #1
0
        public IActionResult OnPostPlus(int id)
        {
            CartItems = HttpContext.Session.GetObjectFromJson <List <ShoppingCart> >("CartItems").ToList();

            var productiInCart = CartItems.SingleOrDefault(x => x.Product.Id == id);
            var cartItemPlus   = cartBL.PlusCartItem(productiInCart);

            CartItems
            .Where(x => x.Id == id)
            .Select(x => { x.Quantity = cartItemPlus.Quantity; return(x); }).ToList();
            if (cartItemPlus.Quantity == productiInCart.Product.Quantity)
            {
                TempData["Message"] = $"You have reached the limit for {productiInCart.Product.Name}!";
            }
            HttpContext.Session.SetObjectAsJson("CartItems", CartItems);
            CartItems = HttpContext.Session.GetObjectFromJson <List <ShoppingCart> >("CartItems").ToList();
            return(RedirectToPage("./ShoppingCart"));
        }