示例#1
0
        public IActionResult NewDish()
        {
            NewDishView viewModel = new NewDishView();

            viewModel.Chefs = dbContext.Chefs.ToList();
            return(View("NewDish", viewModel));
        }
        public NewDishView CreateNewDishView()
        {
            NewDishView NDV = new NewDishView();

            NDV.Chefs = dbContext.Chefs.ToList();
            return(NDV);
        }
 public RedirectToActionResult CreateDish(NewDishView newMeal)
 {
     if (ModelState.IsValid)
     {
         dbContext.Add(newMeal.newDish);
         dbContext.SaveChanges();
         return(RedirectToAction("AllDishes"));
     }
     return(RedirectToAction("NewDish"));
 }
示例#4
0
        public IActionResult AddDish(NewDishView modelView)
        {
            if (ModelState.IsValid)
            {
                Dish newDish = modelView.newDish;

                dbContext.Add(newDish);
                dbContext.SaveChanges();
                return(RedirectToAction("DisplayDishes"));
            }

            return(View("NewDish"));
        }
        public ViewResult NewDish()
        {
            NewDishView ViewModel = CreateNewDishView();

            return(View("NewDish", ViewModel));
        }