Beispiel #1
0
        public IActionResult Index(IceCream ice)
        {
            if (ModelState.IsValid)
            {
                //add to db
                IceCreamDB.Add(ice);

                return(RedirectToAction("Index", "Success"));
            }
            else
            {
                return(View(ice));
            }
        }
Beispiel #2
0
        public IActionResult Index(IFormCollection data)
        {
            IceCream ice = new IceCream();

            ice.Flavor = data["flavor"];
            try
            {
                ice.Scoops = Convert.ToByte(data["scoops"]);
            }
            catch (Exception)
            {
                throw new Exception();
            }
            ice.Container = data["container"];

            //Add to db
            IceCreamDB.Add(ice);

            ViewData["Success"] = "Order Complete!";

            return(View());
        }