public ActionResult ModifyMealView(MealRecipeViewModel model) { if (model != null && model.MealType != null) { int userId = (int)Session[SessionKeys.UserId]; List <int> recipeIds = new List <int>(); List <string> mealTypes = new List <string>(); foreach (var mt in model.MealType) { mealTypes.Add(mt); } Meal meal = new Meal() { MealName = model.MealName, RecipeIds = model.RecipeIds, MealTypes = mealTypes, RecipeNames = model.RecipeNames, MealId = model.MealId }; mealDAL.DeleteRecipesForMeal(userId, meal.MealId); mealDAL.UpdateMeal(meal.MealId, meal.MealName); mealDAL.UpdateMealRecipe(meal, userId); if (userDAL.GetUser((string)Session[SessionKeys.EmailAddress]) != null) { return(RedirectToAction("Detail", "Meal", new { mealId = meal.MealId })); } } return(RedirectToAction("Login", "User")); }