/// <summary> /// The on post event /// </summary> public void OnPost() { Combos = Menu.AvailableCombos; Drinks = Menu.AvailableDrinks; Entrees = Menu.AvailableEntrees; Sides = Menu.AvailableSides; if (search != null) { Combos = Combos.Where(item => item.ToString().Contains(search, StringComparison.OrdinalIgnoreCase)); Drinks = Drinks.Where(item => item.ToString().Contains(search, StringComparison.OrdinalIgnoreCase)); Entrees = Entrees.Where(item => item.ToString().Contains(search, StringComparison.OrdinalIgnoreCase)); Sides = Sides.Where(item => item.ToString().Contains(search, StringComparison.OrdinalIgnoreCase)); } if (minimumPrice != null) { Combos = Combos.Where(item => item.Price >= minimumPrice); Drinks = Drinks.Where(item => item.Price >= minimumPrice); Entrees = Entrees.Where(item => item.Price >= minimumPrice); Sides = Sides.Where(item => item.Price >= minimumPrice); } if (maximumPrice != null) { Combos = Combos.Where(item => item.Price <= maximumPrice); Drinks = Drinks.Where(item => item.Price <= maximumPrice); Entrees = Entrees.Where(item => item.Price <= maximumPrice); Sides = Sides.Where(item => item.Price <= maximumPrice); } if (possibleIngredients.Count > 0) { foreach (string ingredients in possibleIngredients) { Combos = Combos.Where(item => !(item.Ingredients.Contains(ingredients))); Drinks = Drinks.Where(item => !(item.Ingredients.Contains(ingredients))); Entrees = Entrees.Where(item => !(item.Ingredients.Contains(ingredients))); Sides = Sides.Where(item => !(item.Ingredients.Contains(ingredients))); } } if (menuCategory.Count > 0) { } }
public void OnPost() { Combos = Menu.AvailableCombos; Entrees = Menu.AvailableEntrees; Sides = Menu.AvailableSides; Drinks = Menu.AvailableDrinks; if (search != null) { Combos = Combos.Where(combo => combo.Description.Contains(search, StringComparison.OrdinalIgnoreCase)); Entrees = Entrees.Where(entree => entree.Description.Contains(search, StringComparison.OrdinalIgnoreCase)); Sides = Sides.Where(side => side.Description.Contains(search, StringComparison.OrdinalIgnoreCase)); Drinks = Drinks.Where(drink => drink.Description.Contains(search, StringComparison.OrdinalIgnoreCase)); } if (menuCategory.Count != 0) { Combos = Combos.Where(combo => menuCategory.Contains("Combo")); Entrees = Entrees.Where(entree => menuCategory.Contains("Entree")); Sides = Sides.Where(side => menuCategory.Contains("Side")); Drinks = Drinks.Where(drink => menuCategory.Contains("Drink")); } if (ingredients.Count != 0) { foreach (string c in ingredients) { Combos = Combos.Where(combo => !combo.Ingredients.Contains(c)); Entrees = Entrees.Where(entree => !entree.Ingredients.Contains(c)); Sides = Sides.Where(side => !side.Ingredients.Contains(c)); Drinks = Drinks.Where(drink => !drink.Ingredients.Contains(c)); } } if (minimumPrice != null) { Combos = Combos.Where(combo => combo.Price > minimumPrice || Math.Abs(combo.Price - (double)minimumPrice) < .0001); Entrees = Entrees.Where(entree => entree.Price >= minimumPrice || Math.Abs(entree.Price - (double)minimumPrice) < .0001); Sides = Sides.Where(side => side.Price >= minimumPrice || Math.Abs(side.Price - (double)minimumPrice) < .0001); Drinks = Drinks.Where(drink => drink.Price >= minimumPrice || Math.Abs(drink.Price - (double)minimumPrice) < .0001); } if (maximumPrice != null) { Combos = Combos.Where(combo => combo.Price <= maximumPrice || Math.Abs(combo.Price - (double)maximumPrice) < .0001); Entrees = Entrees.Where(entree => entree.Price <= maximumPrice || Math.Abs(entree.Price - (double)maximumPrice) < .0001); Sides = Sides.Where(side => side.Price <= maximumPrice || Math.Abs(side.Price - (double)maximumPrice) < .0001); Drinks = Drinks.Where(drink => drink.Price <= maximumPrice || Math.Abs(drink.Price - (double)maximumPrice) < .0001); } }
public void OnGet() { if (ItemType.Contains("Entrees") || ItemType.Count() == 0) { Entrees = Menu.Entrees(); if (SearchTerms != null) { Entrees = Entrees.Where(entree => entree.Name.Contains(SearchTerms, StringComparison.InvariantCultureIgnoreCase) ); } if (!(CalorieMin == null && CalorieMax == null)) { if (CalorieMax == null) { Entrees = Entrees.Where(entree => entree.Calories >= CalorieMin); } else if (CalorieMin == null) { Entrees = Entrees.Where(entree => entree.Calories <= CalorieMax); } else { Entrees = Entrees.Where(entree => entree.Calories >= CalorieMin && entree.Calories <= CalorieMax); } } if (!(PriceMin == null && PriceMax == null)) { if (PriceMax == null) { Entrees = Entrees.Where(entree => entree.Price >= PriceMin); } else if (PriceMin == null) { Entrees = Entrees.Where(entree => entree.Price <= PriceMax); } else { Entrees = Entrees.Where(entree => entree.Price >= PriceMin && entree.Price <= PriceMax); } } /* * Entrees = Menu.CompleteSearch(Entrees, SearchTerms); * Entrees = Menu.FilterByCalories(Entrees, CalorieMin, CalorieMax); * Entrees = Menu.FilterByPrice(Entrees, PriceMin, PriceMax); */ } if (ItemType.Contains("Sides") || ItemType.Count() == 0) { Sides = Menu.CompleteSearch(Menu.Sides(), SearchTerms); Sides = Menu.FilterByCalories(Sides, CalorieMin, CalorieMax); Sides = Menu.FilterByPrice(Sides, PriceMin, PriceMax); } if (ItemType.Contains("Drinks") || ItemType.Count() == 0) { Drinks = Menu.CompleteSearch(Menu.Drinks(), SearchTerms); Drinks = Menu.FilterByCalories(Drinks, CalorieMin, CalorieMax); Drinks = Menu.FilterByPrice(Drinks, PriceMin, PriceMax); } }
/// <summary> /// Whenever something is clicked this happens /// </summary> public void OnPost() { Combos = Menu.AvailableCombos; Entrees = Menu.AvailableEntrees; Sides = Menu.AvailableSides; MenuItems = Menu.AvailableMenuItems; Drinks = Menu.AvailableDrinks; Menu.AllIngredients(Menu.AvailableCombos); Menu.AllIngredients(Menu.AvailableEntrees); Menu.AllIngredients(Menu.AvailableSides); Menu.AllIngredients(Menu.AvailableDrinks); PossibleIngredientsHashSet = Menu.PossibleIngredients; if (Search != null) { Combos = Combos.Where(combo => combo.ToString().Contains(Search)); Entrees = Entrees.Where(entree => entree.ToString().Contains(Search)); Sides = Sides.Where(side => side.ToString().Contains(Search)); Drinks = Drinks.Where(drink => drink.ToString().Contains(Search)); } if (Filter.Count != 0) { Combos = Combos.Where(combo => combo is CretaceousCombo && Filter.Contains("Combo"));; Entrees = Entrees.Where(entree => entree is Entree && Filter.Contains("Entree")); Sides = Sides.Where(side => side is Side && Filter.Contains("Side")); Drinks = Drinks.Where(drink => drink is Drink && Filter.Contains("Drink")); } if (Ingredients.Count != 0) { Combos = Combos.Where(combo => { bool keep = false; for (int i = 0; i < Ingredients.Count; i++) { if (combo.Ingredients.Contains(Ingredients[i])) { keep = true; } } return(keep); }); Entrees = Entrees.Where(entree => { bool keep = false; for (int i = 0; i < Ingredients.Count; i++) { if (entree.Ingredients.Contains(Ingredients[i])) { keep = true; } } return(keep); }); Sides = Sides.Where(side => { bool keep = false; for (int i = 0; i < Ingredients.Count; i++) { if (side.Ingredients.Contains(Ingredients[i])) { keep = true; } } return(keep); }); Drinks = Drinks.Where(drink => { bool keep = false; for (int i = 0; i < Ingredients.Count; i++) { if (drink.Ingredients.Contains(Ingredients[i])) { keep = true; } } return(keep); }); } if (MinimumPrice != null) { Combos = Combos.Where(combo => combo.Price >= MinimumPrice); Entrees = Entrees.Where(entree => entree.Price >= MinimumPrice); Sides = Sides.Where(side => side.Price >= MinimumPrice); Drinks = Drinks.Where(drink => drink.Price >= MinimumPrice); } if (MaximumPrice != null) { Combos = Combos.Where(combo => combo.Price <= MaximumPrice); Entrees = Entrees.Where(entree => entree.Price <= MaximumPrice); Sides = Sides.Where(side => side.Price <= MaximumPrice); Drinks = Drinks.Where(drink => drink.Price <= MaximumPrice); } }
public void OnPost(string search, List <string> menuCategory, float?minimumPrice, float?maximumPrice, List <string> ingredient) { Menu = new Menu(); Combos = Menu.AvailableCombos; Entrees = Menu.AvailableEntrees; Drinks = Menu.AvailableDrinks; Sides = Menu.AvailableSides; //Filter on name if (search != null) { Combos = Combos.Where(combo => combo.ToString().Contains(search)); Entrees = Entrees.Where(entree => entree.ToString().Contains(search)); Drinks = Drinks.Where(drink => drink.ToString().Contains(search)); Sides = Sides.Where(side => side.ToString().Contains(search)); } //Filter on category if (menuCategory != null) { if (!menuCategory.Contains("Combo")) { Combos = new List <CretaceousCombo>(); } if (!menuCategory.Contains("Entree")) { Entrees = new List <Entree>(); } if (!menuCategory.Contains("Drink")) { Drinks = new List <Drink>(); } if (!menuCategory.Contains("Side")) { Sides = new List <Side>(); } } //Filter on min price if (minimumPrice != null) { Combos = Combos.Where(combo => combo.Price >= minimumPrice); Entrees = Entrees.Where(entree => entree.Price >= minimumPrice); Drinks = Drinks.Where(drink => drink.Price >= minimumPrice); Sides = Sides.Where(side => side.Price >= minimumPrice); } //Filter on max price if (maximumPrice != null) { Combos = Combos.Where(combo => combo.Price <= maximumPrice); Entrees = Entrees.Where(entree => entree.Price <= maximumPrice); Drinks = Drinks.Where(drink => drink.Price <= maximumPrice); Sides = Sides.Where(side => side.Price <= maximumPrice); } //Filter on ingredients if (ingredient != null) { Combos = Combos.Where(combo => combo.Ingredients.Where(ingred => ingredient.Contains(ingred)).Count() == 0); Entrees = Entrees.Where(entree => entree.Ingredients.Where(ingred => ingredient.Contains(ingred)).Count() == 0); Drinks = Drinks.Where(drink => drink.Ingredients.Where(ingred => ingredient.Contains(ingred)).Count() == 0); Sides = Sides.Where(side => side.Ingredients.Where(ingred => ingredient.Contains(ingred)).Count() == 0); } }
/// <summary> /// The Post method responses to the server, use the LINQ Enumberable.Where method /// </summary> public void OnPost() { Combos = Menu.AvailableCombos; Entrees = Menu.AvailableEntrees; Sides = Menu.AvailableSides; Drinks = Menu.AvailableDrinks; Menu.AllIngredients(Menu.AvailableCombos); Menu.AllIngredients(Menu.AvailableEntrees); Menu.AllIngredients(Menu.AvailableSides); Menu.AllIngredients(Menu.AvailableDrinks); Ingre = Menu.PossibleIngredients; if (search != null) { Combos = Combos.Where(combo => combo.ToString().Contains(search)); Entrees = Entrees.Where(entree => entree.ToString().Contains(search)); Sides = Sides.Where(side => side.ToString().Contains(search)); Drinks = Drinks.Where(drink => drink.ToString().Contains(search)); } if (filters.Count != 0) { Combos = Combos.Where(combo => combo is CretaceousCombo && filters.Contains("Combo")); Entrees = Entrees.Where(entree => entree is Entree && filters.Contains("Entree")); Sides = Sides.Where(side => side is Side && filters.Contains("Side")); Drinks = Drinks.Where(drink => drink is Drink && filters.Contains("Drink")); } if (minPrice != null) { Combos = Combos.Where(combo => combo.Price >= minPrice); Entrees = Entrees.Where(entree => entree.Price >= minPrice); Sides = Sides.Where(side => side.Price >= minPrice); Drinks = Drinks.Where(drink => drink.Price >= minPrice); } if (maxPrice != null) { Combos = Combos.Where(combo => combo.Price <= maxPrice); Entrees = Entrees.Where(entree => entree.Price <= maxPrice); Sides = Sides.Where(side => side.Price <= maxPrice); Drinks = Drinks.Where(drink => drink.Price <= maxPrice); } if (ingredients.Count != 0) { Combos = Combos.Where(combo => { List <IMenuItem> results = new List <IMenuItem>(); bool safeToAdd = true; for (int j = 0; j < ingredients.Count; j++) { if (combo.Ingredients.Contains(ingredients[j])) { safeToAdd = false; break; } } return(safeToAdd); }); Entrees = Entrees.Where(entree => { List <IMenuItem> results = new List <IMenuItem>(); bool safeToAdd = true; for (int j = 0; j < ingredients.Count; j++) { if (entree.Ingredients.Contains(ingredients[j])) { safeToAdd = false; break; } } return(safeToAdd); }); Sides = Sides.Where(side => { List <IMenuItem> results = new List <IMenuItem>(); bool safeToAdd = true; for (int j = 0; j < ingredients.Count; j++) { if (side.Ingredients.Contains(ingredients[j])) { safeToAdd = false; break; } } return(safeToAdd); }); Drinks = Drinks.Where(drink => { List <IMenuItem> results = new List <IMenuItem>(); bool safeToAdd = true; for (int j = 0; j < ingredients.Count; j++) { if (drink.Ingredients.Contains(ingredients[j])) { safeToAdd = false; break; } } return(safeToAdd); }); } }
/// <summary> /// Gets the filters, gets new lists using the filters, and reloads the page /// </summary> /// <param name="SearchTerms">Phrase to search for</param> /// <param name="Category">Entree, Side, or Drink</param> /// <param name="PriceMin">Min price</param> /// <param name="PriceMax">Max price</param> /// <param name="CalorieMin">min Calorie</param> /// <param name="CalorieMax">max Calorie</param> public void OnGet(string SearchTerms, string[] Category, double?PriceMin, double?PriceMax, int?CalorieMin, int?CalorieMax) { this.SearchTerms = SearchTerms; this.Category = Category; this.PriceMin = PriceMin; this.PriceMax = PriceMax; this.CalorieMin = CalorieMin; this.CalorieMax = CalorieMax; Entrees = Menu.Entrees(); Sides = Menu.Sides(); Drinks = Menu.Drinks(); if (SearchTerms != null && SearchTerms != "") { string[] array = SearchTerms.Split(' '); int count = 0; foreach (string k in array) { array[count] = k.ToLower(); count++; } Entrees = Entrees.Where(entree => Entrees.ToString() != null && (entree.ToString().Contains(SearchTerms, StringComparison.OrdinalIgnoreCase) || array.Any(entree.Description.ToLower().Contains))); Sides = Sides.Where(side => Sides.ToString() != null && (side.ToString().Contains(SearchTerms, StringComparison.OrdinalIgnoreCase) || array.Any(side.Description.ToLower().Contains))); Drinks = Drinks.Where(drink => Drinks.ToString() != null && (drink.ToString().Contains(SearchTerms, StringComparison.OrdinalIgnoreCase) || array.Any(drink.Description.ToLower().Contains))); } if (Category.Count() != 0) { bool[] cont = new bool[3]; foreach (string item in Category) { switch (item) { case "Entree": cont[0] = true; break; case "Side": cont[1] = true; break; case "Drink": cont[2] = true; break; } } if (!cont[0]) { Entrees = new List <IOrderItem>(); } if (!cont[1]) { Sides = new List <IOrderItem>(); } if (!cont[2]) { Drinks = new List <IOrderItem>(); } } ///?PriceMin=0&PriceMax=1&Category=Side&CalorieMin=0&CalorieMax=100&SearchTerms=vokun if (CalorieMin != null && CalorieMax == null) { Entrees = Entrees.Where(entree => entree.Calories >= CalorieMin); Sides = Sides.Where(side => side.Calories >= CalorieMin); Drinks = Drinks.Where(drink => drink.Calories >= CalorieMin); } if (CalorieMin == null && CalorieMax != null) { Entrees = Entrees.Where(entree => entree.Calories <= CalorieMax); Sides = Sides.Where(side => side.Calories <= CalorieMax); Drinks = Drinks.Where(drink => drink.Calories <= CalorieMax); } if (CalorieMin != null && CalorieMax != null) { Entrees = Entrees.Where(entree => entree.Calories >= CalorieMin && entree.Calories <= CalorieMax); Sides = Sides.Where(side => side.Calories >= CalorieMin && side.Calories <= CalorieMax); Drinks = Drinks.Where(drink => drink.Calories >= CalorieMin && drink.Calories <= CalorieMax); } if (PriceMin != null && PriceMax == null) { Entrees = Entrees.Where(entree => entree.Price >= PriceMin); Sides = Sides.Where(side => side.Price >= PriceMin); Drinks = Drinks.Where(drink => drink.Price >= PriceMin); } if (PriceMin == null && PriceMax != null) { Entrees = Entrees.Where(entree => entree.Price <= PriceMax); Sides = Sides.Where(side => side.Price <= PriceMax); Drinks = Drinks.Where(drink => drink.Price <= PriceMax); } if (PriceMin != null && PriceMax != null) { Entrees = Entrees.Where(entree => entree.Price >= PriceMin && entree.Price <= PriceMax); Sides = Sides.Where(side => side.Price >= PriceMin && side.Price <= PriceMax); Drinks = Drinks.Where(drink => drink.Price >= PriceMin && drink.Price <= PriceMax); } Entrees = Entrees.ToList(); Sides = Sides.ToList(); Drinks = Drinks.ToList(); /* * Entrees = Menu.Search(Entrees, SearchTerms); * Sides = Menu.Search(Sides, SearchTerms); * Drinks = Menu.Search(Drinks, SearchTerms); * * Entrees = Menu.FilterByCategory(Entrees, Category); * Sides = Menu.FilterByCategory(Sides, Category); * Drinks = Menu.FilterByCategory(Drinks, Category); * * Entrees = Menu.FilterByCalories(Entrees, CalorieMin, CalorieMax); * Sides = Menu.FilterByCalories(Sides, CalorieMin, CalorieMax); * Drinks = Menu.FilterByCalories(Drinks, CalorieMin, CalorieMax); * * Entrees = Menu.FilterByPrice(Entrees, PriceMin, PriceMax); * Sides = Menu.FilterByPrice(Sides, PriceMin, PriceMax); * Drinks = Menu.FilterByPrice(Drinks, PriceMin, PriceMax);*/ }
/// <summary> /// filters the items when the page is sent a request /// </summary> /// <param name="SearchTerms"></param> /// <param name="OrderTypes"></param> /// <param name="calMin"></param> /// <param name="calMax"></param> /// <param name="priceMin"></param> /// <param name="priceMax"></param> public void OnGet(string SearchTerms, string[] OrderTypes, int?calMin, int?calMax, double?priceMin, double?priceMax) { if (SearchTerms != null) { string[] words = SearchTerms.Split(' '); for (int i = 0; i < words.Length; i++) { words[i] = words[i].ToLower(); } //Entrees = Menu.Entrees().Where(item => item.ToString().Contains(SearchTerms, StringComparison.InvariantCultureIgnoreCase)); Entrees = Menu.Entrees().Where(item => words.Any(item.ToString().ToLower().Contains) || words.Any(item.Description.ToLower().Contains)); Drinks = Menu.Drinks().Where(item => words.Any(item.ToString().ToLower().Contains) || words.Any(item.Description.ToLower().Contains)); Sides = Menu.Sides().Where(item => words.Any(item.ToString().ToLower().Contains) || words.Any(item.Description.ToLower().Contains)); // Drinks = Menu.Drinks().Where(item => item.ToString().Contains(SearchTerms, StringComparison.InvariantCultureIgnoreCase)); // Sides = Menu.Sides().Where(item => item.ToString().Contains(SearchTerms, StringComparison.InvariantCultureIgnoreCase)); //DO MULTIPLE WORDS AND DESCRIPTION } if (OrderTypes != null && OrderTypes.Length != 0) { Entrees = Entrees.Where(item => item.Type != null && OrderTypes.Contains(item.Type) ); Drinks = Drinks.Where(item => item.Type != null && OrderTypes.Contains(item.Type) ); Sides = Sides.Where(item => item.Type != null && OrderTypes.Contains(item.Type) ); } if (calMin != null && calMax != null) { Entrees = Entrees.Where(item => item.Calories >= calMin && item.Calories <= calMax ); Drinks = Drinks.Where(item => item.Calories >= calMin && item.Calories <= calMax ); Sides = Sides.Where(item => item.Calories >= calMin && item.Calories <= calMax ); } if (priceMin != null && priceMax != null) { Entrees = Entrees.Where(item => item.Price >= priceMin && item.Price <= priceMax ); Drinks = Drinks.Where(item => item.Price >= priceMin && item.Price <= priceMax ); Sides = Sides.Where(item => item.Price >= priceMin && item.Price <= priceMax ); } //Entrees = Menu.Search(Menu.Entrees(),SearchTerms); //Drinks = Menu.Search(Menu.Drinks(), SearchTerms); //Sides = Menu.Search(Menu.Sides(), SearchTerms); //Entrees = Menu.FilterByCategory(Entrees, OrderTypes); //Drinks = Menu.FilterByCategory(Drinks, OrderTypes); //Sides = Menu.FilterByCategory(Sides, OrderTypes); //Entrees = Menu.FilterByCalories(Entrees, calMin, calMax); //Drinks = Menu.FilterByCalories(Drinks, calMin, calMax); //Sides = Menu.FilterByCalories(Sides, calMin, calMax); //Entrees = Menu.FilterByPrice(Entrees, priceMin, priceMax); //Drinks = Menu.FilterByPrice(Drinks, priceMin, priceMax); //Sides = Menu.FilterByPrice(Sides, priceMin, priceMax); }