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)); } }
// GET: Recipe/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RecipeBaseViewModel recipe = m.RecipeGetById(id); if (recipe == null) { return(HttpNotFound()); } return(View(recipe)); }
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)); }
// GET: Recipe/VoteDown/5 public ActionResult VoteDown(int?id) { RecipeBaseViewModel recipe = m.RecipeGetById(id); //use recipe id and logged in user's name if (recipe == null) { return(HttpNotFound()); } bool voteMade = m.CheckForVote(recipe.recipe_Id); if (!voteMade) { m.AlterRating(recipe.recipe_Id, -1); } else { return(View("AlreadyVoted")); } return(RedirectToAction("Details", "Recipe", new { id = recipe.recipe_Id })); }
// GET: Recipe/VoteDown/5 public ActionResult VoteDown(int?id) { RecipeBaseViewModel recipe = m.RecipeGetById(id); //use recipe id and logged in user's name if (recipe == null) { return(HttpNotFound()); } bool voteMade = m.CheckForVoteDown(recipe.recipe_Id); if (!voteMade) { m.AlterRating(recipe.recipe_Id, -1); } else { //Uses the bookmark variable to store vote status, as another function for vote variables cannot be created (avoids ambiguous function call error) return(RedirectToAction("Details", new { id = recipe.recipe_Id, bookmark = "N" })); } return(RedirectToAction("Details", new { id = recipe.recipe_Id, bookmark = "Y" })); }