示例#1
0
        public ActionResult AddMealIngredientToMeal(MealIngredientViewModel ingredientToAdd)
        {
            var MealDBInterface = new MealDAO();
            var mealId          = ingredientToAdd.MealId;

            if (MealDBInterface.ingredientAlreadyInMeal(ingredientToAdd))
            {
                ModelState.AddModelError("CustomError", "Ingredient already in Fridge");
                return(View());
            }
            else
            {
                MealDBInterface.AddIngredientToMeal(ingredientToAdd);
            }

            var mealToDisplay = new MealViewModel();

            mealToDisplay = MealDBInterface.FetchMeal(mealId);
            return(View("Mealform", mealToDisplay));
        }