Ejemplo n.º 1
0
        public ActionResult Search(FormCollection col)
        {
            SearchItems searchItems = default(SearchItems);

            // added this items to the model in a struct so we can continue using same search items
            // ternary : if hidden element is null, use original search page element, else use hidden element

            searchItems.query               = col["hquery"] == null ? col["SearchQuery"] : col["hquery"];
            searchItems.cuisine             = col["hcuisine"] == null ? col["Cuisine"] : col["hcuisine"];
            searchItems.ingredients         = col["hingredients"] == null ? col["Ingredients"] : col["hingredients"];
            searchItems.diets               = col["hdiets"] == null ? col["Diets"] : col["hdiets"];
            searchItems.excludedIngredients = col["hexcludedIngredients"] == null ? col["ExcludedIngredients"] : col["hexcludedIngredients"];
            searchItems.intolerances        = col["hintolerances"] == null ? col["Intolerances"] : col["hintolerances"];
            searchItems.type  = col["htype"] == null ? col["Type"] : col["htype"];
            searchItems.index = col["hindex"] == null ? 0 : Convert.ToInt32(col["hindex"]) + 1;

            // update to search model when that is created
            Models.HomeContent h = new Models.HomeContent
            {
                searchItems = searchItems,
                // get recipes to display
                SearchResults = RecipeAPI.RecipeSearch(searchItems.query, searchItems.cuisine, searchItems.ingredients,
                                                       searchItems.diets, searchItems.excludedIngredients, searchItems.intolerances, searchItems.type, searchItems.index)

                                // get the user object when we set up users
            };

            return(View(h));
        }
Ejemplo n.º 2
0
        public ActionResult Index( )
        {
            Models.HomeContent h = new Models.HomeContent
            {
                // get recipes to display
                RecipesToDisplay = RecipeAPI.Get5RandomAPIRecipes( )

                                   // get the user object when we set up users
            };

            return(View(h));
        }
Ejemplo n.º 3
0
        public ActionResult Recipe(  )
        {
            // update to search model when that is created
            Models.HomeContent h = new Models.HomeContent
            {
                // get recipes to display
                SingleRecipe = RecipeAPI.GetRecipeById(Convert.ToString(RouteData.Values["id"]))

                               // get the user object when we set up users
            };

            return(View(h));
        }
Ejemplo n.º 4
0
 public bool InsertHomeContent(Models.HomeContent HomeEntity)
 {
     if (HomeEntity != null)
     {
         _Homedb.AddToHomeContents(HomeEntity);
         _Homedb.SaveChanges();
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 5
0
        public ActionResult Index( )
        {
            Models.Database    db = new Models.Database( );
            Models.HomeContent h  = new Models.HomeContent( );

            h.Events = new List <Models.Event>( );
            h.Events = db.GetActiveEvents( );

            h.User = new Models.User( );
            h.User = h.User.GetUserSession( );

            if (h.User.IsAuthenticated)
            {
                h.User.Likes   = db.GetEventLikes(h.User.UID);
                h.User.Ratings = db.GetEventRatings(h.User.UID);
            }
            return(View(h));
        }
Ejemplo n.º 6
0
        public ActionResult Search( )
        {
            Models.HomeContent h = new Models.HomeContent();

            return(View(h));
        }