public ActionResult DeleteMealView(MealRecipeViewModel mrvm) { if (userDAL.GetUser((string)Session[SessionKeys.EmailAddress]) == null) { return(RedirectToAction("Login", "User")); } Meal m = new Meal(); m.MealId = mrvm.MealId; int userId = (int)Session[SessionKeys.UserId]; mealDAL.DeleteMealRecipe(userId, m.MealId); TempData["action"] = "delete"; return(RedirectToAction("Index")); }
public ActionResult DeleteRecipeView(RecipeViewModel rvm) { if (userDAL.GetUser((string)Session[SessionKeys.EmailAddress]) == null) { return(RedirectToAction("Login", "User")); } Recipe r = new Recipe(); r.RecipeId = rvm.RecipeId; r.UserId = (int)Session[SessionKeys.UserId]; recipeIngredientDAL.DeleteFromRecipeIngredient(r.RecipeId); preparationStepsDAL.DeleteFromPreparationSteps(r.RecipeId); mealDAL.DeleteMealRecipe(r.UserId, r.RecipeId); recipeDAL.DeleteRecipe(r); TempData["action"] = "delete"; return(RedirectToAction("Recipes")); }