예제 #1
0
        public IActionResult Create([Bind("Type,SpoonsOfSugar,UseOwnMug")] CoffeeModel coffeeModel)
        {
            if (ModelState.IsValid)
            {
                //Mapping model with the Entity
                Coffee coffee = new Coffee();
                coffee.Type          = (Entities.CoffeeType)coffeeModel.Type;
                coffee.SpoonsOfSugar = coffeeModel.SpoonsOfSugar;
                coffee.UseOwnMug     = coffeeModel.UseOwnMug;
                coffee.DateOrdered   = DateTime.Now;

                _logic.CreateCoffee(coffee);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(coffeeModel));
        }