public ActionResult ReportRecipe(ReportRecipeViewModel reportRecipe) { RecipeBaseViewModel recipe = m.RecipeGetById(reportRecipe.recipeId); reportRecipe.recipeTitle = recipe.title; reportRecipe.userName = m.GetCurrentUsername(); string username = m.GetCurrentUsername(); if (!ModelState.IsValid) { return(View(reportRecipe)); } int error = m.ReportRecipe(reportRecipe); if (error == 1) { return(RedirectToAction("ReportedRecipe", new { succError = error })); } else if (error == 0) { return(RedirectToAction("ReportedRecipe", new { succError = error })); } else { ModelState.AddModelError("", "An error occurred while sending an email. Please try again!"); return(View(reportRecipe)); } }
public ActionResult ReportRecipe(int?id) { string username = m.GetCurrentUsername(); if (id == null) { return(View()); } RecipeBaseViewModel recipe = m.RecipeGetById(id); ReportRecipeViewModel reportRecipe = new ReportRecipeViewModel(); reportRecipe.recipeId = recipe.recipe_Id; reportRecipe.userName = username; reportRecipe.recipeTitle = recipe.title; return(View(reportRecipe)); }
public ActionResult ReportRecipe(ReportRecipeViewModel reportRecipe) { int error = m.ReportRecipe(reportRecipe); if (error == 1) { return(RedirectToAction("ReportedRecipe", new { succError = error })); } else if (error == 0) { return(RedirectToAction("ReportedRecipe", new { succError = error })); } else { ModelState.AddModelError("", "An error occurred while sending an email. Please try again!"); return(View()); } }