Esempio n. 1
0
        public async Task <IActionResult> Buy(int id)
        {
            var value = new byte[0];

            if (HttpContext.Session.Keys.Contains("basket"))
            {
                value = HttpContext.Session.Get("basket");
            }

            if (!await db.IsAvailable(id))
            {
                return(RedirectToAction("Error",
                                        new ErrorViewModel()
                {
                    ActionName = "Catalog",
                    RequestInfo = "Product not available"
                }));
            }

            HttpContext.Session.Set("basket", value.AddValue(id));

            return(RedirectToAction("Basket"));
        }