Exemple #1
0
        public IActionResult OnPost()
        {
            NewProduct.Description = ProductDescription;
            NewProduct.Id          = OldProduct.Id;
            int click = Int32.Parse(Request.Form["click"]);

            if (click == 1)
            {
                ProductsDB.UpdateProduct(NewProduct, _configuration);
                string currentShoppingCart = Request.Cookies["ShoppingCart"];
                if (currentShoppingCart != null && currentShoppingCart != "")
                {
                    string newShoppingCart = ProductsCookies.UpdateProduct(currentShoppingCart, NewProduct);
                    var    cookieOptions   = new CookieOptions {
                        Expires = DateTime.Now.AddDays(1)
                    };
                    Response.Cookies.Append("ShoppingCart", newShoppingCart, cookieOptions);
                }
                return(RedirectToPage("/Index"));
            }
            else
            {
                return(RedirectToPage("/Index"));
            }
        }