public IActionResult Create(Meal m) { m.Ingredients = new List <Ingredient>(); if (ModelState.IsValid) { if (m.MealTypeId == 7 && m.Price < 200) { ModelState.AddModelError("Price", "Price for Dessert should be at least 200."); return(View()); } List <Ingredient> ingredients = FillModels.FillIngredients(); foreach (Ingredient i in ingredients) { foreach (string s in m.IList) { if (i.Name == s) { m.Ingredients.Add(i); break; } } } m.IList = null; m.AddToFile(m); return(RedirectToAction("Meal")); } return(View()); }