示例#1
0
        /// <summary>
        /// Handles form submissions, displays the page content after searching and filtering is applied.
        /// </summary>
        public void OnPost()
        {
            AvailableCombos  = Menu.AvailableCombos;
            AvailableEntrees = Menu.AvailableEntrees;
            AvailableSides   = Menu.AvailableSides;
            AvailableDrinks  = Menu.AvailableDrinks;

            if (search != null)
            {
                AvailableCombos  = AvailableCombos.Where(item => item.ToString().Contains(search, StringComparison.OrdinalIgnoreCase));
                AvailableEntrees = AvailableEntrees.Where(item => item.ToString().Contains(search, StringComparison.OrdinalIgnoreCase));
                AvailableSides   = AvailableSides.Where(item => item.ToString().Contains(search, StringComparison.OrdinalIgnoreCase));
                AvailableDrinks  = AvailableDrinks.Where(item => item.ToString().Contains(search, StringComparison.OrdinalIgnoreCase));
            }

            if (minimumPrice != null && minimumPrice < maximumPrice)
            {
                AvailableCombos  = AvailableCombos.Where(item => item.Price >= minimumPrice);
                AvailableEntrees = AvailableEntrees.Where(item => item.Price >= minimumPrice);
                AvailableSides   = AvailableSides.Where(item => item.Price >= minimumPrice);
                AvailableDrinks  = AvailableDrinks.Where(item => item.Price >= minimumPrice);
            }

            if (maximumPrice != null && maximumPrice > minimumPrice)
            {
                AvailableCombos  = AvailableCombos.Where(item => item.Price <= maximumPrice);
                AvailableEntrees = AvailableEntrees.Where(item => item.Price <= maximumPrice);
                AvailableSides   = AvailableSides.Where(item => item.Price <= maximumPrice);
                AvailableDrinks  = AvailableDrinks.Where(item => item.Price <= maximumPrice);
            }

            if (possibleIngredients.Count > 0)
            {
                foreach (string i in possibleIngredients)
                {
                    AvailableCombos  = AvailableCombos.Where(item => !item.Ingredients.Contains(i));
                    AvailableEntrees = AvailableEntrees.Where(item => !item.Ingredients.Contains(i));
                    AvailableSides   = AvailableSides.Where(item => !item.Ingredients.Contains(i));
                    AvailableDrinks  = AvailableDrinks.Where(item => !item.Ingredients.Contains(i));
                }
            }
        }
示例#2
0
        /// <summary>
        /// Method for each attribute set to post
        /// </summary>
        public void OnPost()
        {
            AvailableCombos  = Menu.AvailableCombos;
            AvailableEntrees = Menu.AvailableEntrees;
            AvailableSides   = Menu.AvailableSides;
            AvailableDrinks  = Menu.AvailableDrinks;

            if (search != null)
            {
                //SearchName(search);
                AvailableCombos = AvailableCombos.Where(item => item.Description.Contains(search,
                                                                                          StringComparison.OrdinalIgnoreCase));

                AvailableEntrees = AvailableEntrees.Where(item => item.Description.Contains(search,
                                                                                            StringComparison.OrdinalIgnoreCase));

                AvailableSides = AvailableSides.Where(item => item.Description.Contains(search,
                                                                                        StringComparison.OrdinalIgnoreCase));

                AvailableDrinks = AvailableDrinks.Where(item => item.Description.Contains(search,
                                                                                          StringComparison.OrdinalIgnoreCase));
            }
            // MIN PRICE
            if (minPrice != null)
            {
                if (minPrice is float minimumPrice)
                {
                    AvailableCombos  = AvailableCombos.Where(item => item.Price >= minimumPrice);
                    AvailableEntrees = AvailableEntrees.Where(item => item.Price >= minimumPrice);
                    AvailableSides   = AvailableSides.Where(item => item.Price >= minimumPrice);
                    AvailableDrinks  = AvailableDrinks.Where(item => item.Price >= minimumPrice);
                }
            }
            // MAX PRICE
            if (maxPrice != null)
            {
                if (maxPrice is float maximumPrice)
                {
                    AvailableCombos  = AvailableCombos.Where(item => item.Price <= maximumPrice);
                    AvailableEntrees = AvailableEntrees.Where(item => item.Price <= maximumPrice);
                    AvailableEntrees = AvailableEntrees.Where(item => item.Price <= maximumPrice);
                    AvailableDrinks  = AvailableDrinks.Where(item => item.Price <= maximumPrice);
                }
            }

            if (menuCategory.Count != 0)
            {
                if (!menuCategory.Contains("Combo"))
                {
                    AvailableCombos = new List <CretaceousCombo>();
                }
                if (!menuCategory.Contains("Entree"))
                {
                    AvailableEntrees = new List <Entree>();
                }
                if (!menuCategory.Contains("Side"))
                {
                    AvailableSides = new List <Side>();
                }
                if (!menuCategory.Contains("Drink"))
                {
                    AvailableDrinks = new List <Drink>();
                }
            }


            //INGREDIENT
            if (ingredient.Count > 0)
            {
                AvailableCombos = AvailableCombos.Where(item =>
                {
                    foreach (string i in ingredient)
                    {
                        if (item.Ingredients.Contains(i))
                        {
                            return(false);
                        }
                    }
                    return(true);
                });

                AvailableEntrees = AvailableEntrees.Where(item =>
                {
                    foreach (string i in ingredient)
                    {
                        if (item.Ingredients.Contains(i))
                        {
                            return(false);
                        }
                    }
                    return(true);
                });

                AvailableSides = AvailableSides.Where(item =>
                {
                    foreach (string i in ingredient)
                    {
                        if (item.Ingredients.Contains(i))
                        {
                            return(false);
                        }
                    }
                    return(true);
                });

                AvailableDrinks = AvailableDrinks.Where(item =>
                {
                    foreach (string i in ingredient)
                    {
                        if (item.Ingredients.Contains(i))
                        {
                            return(false);
                        }
                    }
                    return(true);
                });
            }
        } // End of OnPost method
示例#3
0
        /// <summary>
        /// Method executed whenever a post request is recieved for the current page. Searches and filters
        /// the menu items on the page and then returns the ones that match the filters.
        /// </summary>
        public void OnPost()
        {
            if (Menu == null)
            {
                Menu = new Menu();
            }

            AvailableCombos  = Menu.AvailableCombos;
            AvailableEntrees = Menu.AvailableEntrees;
            AvailableSides   = Menu.AvailableSides;
            AvailableDrinks  = Menu.AvailableDrinks;

            if (search != null)
            {
                //AvailableCombos = Menu.Search(AvailableCombos, search);
                AvailableCombos = AvailableCombos.Where(item => item.Description.Replace("Small", "")
                                                        .Contains(search, StringComparison.CurrentCultureIgnoreCase));

                //AvailableEntrees = Menu.Search(AvailableEntrees, search);
                AvailableEntrees = AvailableEntrees.Where(item => item.Description.Replace("Small", "")
                                                          .Contains(search, StringComparison.CurrentCultureIgnoreCase));

                //AvailableSides = Menu.Search(AvailableSides, search);
                AvailableSides = AvailableSides.Where(item => item.Description.Replace("Small", "")
                                                      .Contains(search, StringComparison.CurrentCultureIgnoreCase));

                //AvailableDrinks = Menu.Search(AvailableDrinks, search);
                AvailableDrinks = AvailableDrinks.Where(item => item.Description.Replace("Small", "")
                                                        .Contains(search, StringComparison.CurrentCultureIgnoreCase));
            }

            if (menuCategory.Count > 0)
            {
                if (!menuCategory.Contains("Combo"))
                {
                    AvailableCombos = new List <CretaceousCombo>();
                }

                if (!menuCategory.Contains("Entree"))
                {
                    AvailableEntrees = new List <Entree>();
                }

                if (!menuCategory.Contains("Side"))
                {
                    AvailableSides = new List <Side>();
                }

                if (!menuCategory.Contains("Drink"))
                {
                    AvailableDrinks = new List <Drink>();
                }
            }

            if (minimumPrice is float min)
            {
                //AvailableCombos = Menu.FilterByMinimumPrice(AvailableCombos, min);
                AvailableCombos = AvailableCombos.Where(item => item.Price >= min);

                //AvailableEntrees = Menu.FilterByMinimumPrice(AvailableEntrees, min);
                AvailableEntrees = AvailableEntrees.Where(item => item.Price >= min);

                //AvailableSides = Menu.FilterByMinimumPrice(AvailableSides, min);
                AvailableSides = AvailableSides.Where(item => item.Price >= min);

                //AvailableDrinks = Menu.FilterByMinimumPrice(AvailableDrinks, min);
                AvailableDrinks = AvailableDrinks.Where(item => item.Price >= min);
            }

            if (maximumPrice is float max)
            {
                //AvailableCombos = Menu.FilterByMaximumPrice(AvailableCombos, max);
                AvailableCombos = AvailableCombos.Where(item => item.Price <= max);

                //AvailableEntrees = Menu.FilterByMaximumPrice(AvailableEntrees, max);
                AvailableEntrees = AvailableEntrees.Where(item => item.Price <= max);

                //AvailableSides = Menu.FilterByMaximumPrice(AvailableSides, max);
                AvailableSides = AvailableSides.Where(item => item.Price <= max);

                //AvailableDrinks = Menu.FilterByMaximumPrice(AvailableDrinks, max);
                AvailableDrinks = AvailableDrinks.Where(item => item.Price <= max);
            }

            if (excludedIngredients.Count > 0)
            {
                //AvailableCombos = Menu.FilterByExcludedIngredients(AvailableCombos, excludedIngredients);
                AvailableCombos = AvailableCombos.Where(item =>
                {
                    foreach (string ingredient in excludedIngredients)
                    {
                        if (item.Ingredients.Contains(ingredient))
                        {
                            return(false);
                        }
                    }

                    return(true);
                });

                //AvailableEntrees = Menu.FilterByExcludedIngredients(AvailableEntrees, excludedIngredients);
                AvailableEntrees = AvailableEntrees.Where(item =>
                {
                    foreach (string ingredient in excludedIngredients)
                    {
                        if (item.Ingredients.Contains(ingredient))
                        {
                            return(false);
                        }
                    }

                    return(true);
                });

                //AvailableSides = Menu.FilterByExcludedIngredients(AvailableSides, excludedIngredients);
                AvailableSides = AvailableSides.Where(item =>
                {
                    foreach (string ingredient in excludedIngredients)
                    {
                        if (item.Ingredients.Contains(ingredient))
                        {
                            return(false);
                        }
                    }

                    return(true);
                });

                //AvailableDrinks = Menu.FilterByExcludedIngredients(AvailableDrinks, excludedIngredients);
                AvailableDrinks = AvailableDrinks.Where(item =>
                {
                    foreach (string ingredient in excludedIngredients)
                    {
                        if (item.Ingredients.Contains(ingredient))
                        {
                            return(false);
                        }
                    }

                    return(true);
                });
            }
        }