예제 #1
0
        public ActionResult SearchRecipe(RecipeSearch search)
        {
            //run the search function and send back the results
            List <Recipe>         searchResults    = oFactory.recipeEndpoint.searchRecipes(search);
            List <RecipeItemView> viewModelResults = new List <RecipeItemView>();

            foreach (Recipe result in searchResults)
            {
                RecipeItemView riv = new RecipeItemView();
                riv.Recipe        = result;
                riv.CreatedByUser = oFactory.userEndpoint.getUserById(result.UserID);
                riv.Reviews       = oFactory.reviewEndpoint.getReviewsForRecipe(result.RecipeID);
                viewModelResults.Add(riv);
            }
            search.SearchResults = viewModelResults;
            return(View(search));
        }
예제 #2
0
 public ActionResult ReviewRecipe(Review review)
 {
     review.timestamp = DateTime.Now;
     //if we successfully added the review then return to the recipe page for it
     if (oFactory.reviewEndpoint.addReview(review))
     {
         RecipeItemView riv = new RecipeItemView();
         riv.Recipe        = oFactory.recipeEndpoint.getRecipeByID(review.recipeId);
         riv.Reviews       = oFactory.reviewEndpoint.getReviewsForRecipe(review.recipeId);
         riv.CreatedByUser = oFactory.userEndpoint.getUserById(riv.Recipe.UserID);
         return(View("ViewRecipe", riv));
         //if we couldn't add the review then go back to the review page
     }
     else
     {
         review.errorMessages.Add("Your review was unable to be added. Please try again.");
         return(View(review));
     }
 }
예제 #3
0
        public ActionResult ViewRecipe(int RecipeID)
        {
            //get the individual recipe they want to view
            Recipe         recipe = oFactory.recipeEndpoint.getRecipeByID(RecipeID);
            RecipeItemView riv    = new RecipeItemView();

            riv.Recipe        = recipe;
            riv.Reviews       = oFactory.reviewEndpoint.getReviewsForRecipe(recipe.RecipeID);
            riv.CreatedByUser = oFactory.userEndpoint.getUserById(recipe.UserID);
            if (recipe != null)
            {
                return(View(riv));
            }
            else
            {
                //if we couldn't find the recipe send the back to the search page
                return(View("SearchRecipe"));
            }
        }