コード例 #1
0
        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));
            }
        }
コード例 #2
0
        // 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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        // 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 }));
        }
コード例 #5
0
        // 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" }));
        }