public IActionResult OnPost(int WhiskeyId)
        {
            Order.CustomerName = User.FindFirst("fullname").Value;
            Order.Whiskey      = whiskeyData.Getall().FirstOrDefault(a => a.Id == WhiskeyId);
            Whiskey            = whiskeyData.GetById(WhiskeyId);

            NewSupply = Whiskey.Supply - Order.AmountBottles;
            whiskeyData.AddOrder(Order);
            whiskeyData.Update(Order.Whiskey, NewSupply);
            whiskeyData.Commit();
            TempData["Message"] = "Your order is placed!";

            return(RedirectToPage("./Index"));
        }
示例#2
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                WhiskeyTypes  = htmlHelper.GetEnumSelectList <WhiskeyType>();
                WhiskeyBrands = htmlHelper.GetEnumSelectList <WhiskeyBrand>();
                WhiskeyArea   = htmlHelper.GetEnumSelectList <WhiskeyArea>();

                return(Page());
            }

            if (Whiskey.Id > 0)
            {
                whiskeyData.Update(Whiskey);
            }
            else
            {
                whiskeyData.Add(Whiskey);
            }
            whiskeyData.Commit();
            TempData["Message"] = "Whiskey saved!";
            return(RedirectToPage("./Detail", new { whiskeyId = Whiskey.Id }));
        }