public void ToStringShouldGiveName(Type type, string name) { Entrees entree = (Entrees)Activator.CreateInstance(type); CretaceousCombo combo = new CretaceousCombo(entree); Assert.Equal(name, combo.ToString()); }
public override void Save() { Stream fichier = File.Create("sav.xml"); XmlSerializer serializer = new XmlSerializer(Entrees.GetType()); serializer.Serialize(fichier, Entrees); fichier.Close(); }
public void Setup() { Entree steak = new Entree("T-Bone", "prime cut grilled to your liking", 15d, 300, 12, 8); Entree burger = new Entree("Cheese Burger", "1/4pounder with lettace, bacon and cheese", 10, 10, 10, 10); Entree chicken = new Entree("Spicy Chicken Sandwich", "grilled chicken breast on bun", 12, 10, 10, 10); Entrees.AddRange(new Entree[] { steak, burger, chicken }); }
/// <summary> /// adds wings to the order /// </summary> private void OnSelectPterodactylWings(object sender, RoutedEventArgs args) { if (DataContext is Order order) { entree = new PterodactylWings(); order.Add(entree); NavigationService.Navigate(new MenuCategorySelection()); } }
public void CretaceousComboChangingSizeShouldNotifyPropertyChanges(Type type, Size size, string propertyName) { Entrees entree = (Entrees)Activator.CreateInstance(type); CretaceousCombo combo = new CretaceousCombo(entree); Assert.PropertyChanged(combo, propertyName, () => { combo.Size = size; }); }
public override void Save() { Entrees.Add(new Entree("Nom1", 50)); Entrees.Add(new Entree("Nom2", 25)); Stream fichier = File.Create("sav.json"); DataContractJsonSerializer serializer = new DataContractJsonSerializer(Entrees.GetType()); serializer.WriteObject(fichier, Entrees); fichier.Close(); }
public override void Load() { if (File.Exists("sav.xml")) { Stream fichier = File.OpenRead("sav.xml"); XmlSerializer serializer = new XmlSerializer(Entrees.GetType()); Object obj = serializer.Deserialize(fichier); Console.WriteLine("Objet récupéré par désérialisation Xml " + obj); Entrees = (List <Entree>)obj; fichier.Close(); } }
/// <summary> /// the constructor /// </summary> /// <param name="entree"></param> /// <param name="combo"></param> public CustomizePBJ(Entrees entree, bool combo, CretaceousCombo cc) { InitializeComponent(); this.cc = cc; this.combo = combo; if (entree is PrehistoricPBJ pbj) { peanutButter.Visibility = Visibility.Visible; Jelly.Visibility = Visibility.Visible; this.entree = pbj; } if (entree is Brontowurst bw) { onions.Visibility = Visibility.Visible; bun.Visibility = Visibility.Visible; peppers.Visibility = Visibility.Visible; this.entree = bw; } if (entree is DinoNuggets dn) { nugget.Visibility = Visibility.Visible; this.entree = dn; } if (entree is SteakosaurusBurger sb) { mustard.Visibility = Visibility.Visible; ketchup.Visibility = Visibility.Visible; pickles.Visibility = Visibility.Visible; bun.Visibility = Visibility.Visible; this.entree = sb; } if (entree is TRexKingBurger tx) { Tomate.Visibility = Visibility.Visible; lettuce.Visibility = Visibility.Visible; mustard.Visibility = Visibility.Visible; ketchup.Visibility = Visibility.Visible; mayo.Visibility = Visibility.Visible; pickles.Visibility = Visibility.Visible; onions.Visibility = Visibility.Visible; bun.Visibility = Visibility.Visible; this.entree = tx; } if (entree is VelociWrap vw) { cheese.Visibility = Visibility.Visible; dressing.Visibility = Visibility.Visible; lettuce.Visibility = Visibility.Visible; this.entree = vw; } }
/// <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 TestMain() { /*List<String> sousjacents = new List<string>(){ "accor", "bnp" }; * Entrees entree = new Entrees(Entrees.typeOption.Basket * , 9, new DateTime(2009, 1, 1) * , sousjacents * , new DateTime(2010, 1, 1) * , new DateTime(2009, 1, 1) * , 10 * , Entrees.typeDonnees.Simulees * , "optionTest" * ,new List<double>() { 0.7, 0.3 }); * Simulation sim = new Simulation(entree);*/ List <String> sousjacent = new List <string>() { "EDF FP", "BNP FP" }; Entrees entree = new Entrees(Entrees.typeOption.Basket , 9, new DateTime(2009, 1, 1) , sousjacent , new DateTime(2011, 1, 1) , new DateTime(2009, 1, 1) , 100 , typeDonnees.typedonnees.Simulees , "optionTest" , new List <double>() { 0.5, 0.5 }); Simulation sim = new Simulation(entree); DataSimu dataSimu = new DataSimu(Simulation.CreerOption(entree)); dataSimu.genereData(entree.debutSimulation); //sim.Lancer(); // DataHisto data = new DataHisto(Simulation.CreerOption(entree)); //data.genereData(entree.dateDebut); //Console.WriteLine("Vol = " + data.vol(0)[1]); //List<DataFeed> dataSimul = data.genereData(entree); //DataHisto.matriceCovariance(entree, dataSimul); //DataHisto data = new DataHisto(); //data.getData(entree); //Compute_Tools.getAssets(dataSimul, entree); }
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); } }
private void Button_Start(object sender, RoutedEventArgs e) { //MAIN A JOUR //Console.WriteLine(strikeUI.Text); //Console.WriteLine(mat.Text); //DateTime debut = Convert.ToDateTime(debutUI.Text); DateTime mat = new DateTime(); // DateTime maturite = Convert.ToDateTime(mat.Text); //int freq = Convert.ToInt32(freqUI.Text); double strike = 0.0; List <String> sousjacents = new List <string>() { "accor", "bnp" }; /*this.entree = new Entrees(Entrees.typeOption.Basket * , 9, new DateTime(2010, 1,1) * , sousjacents * , new DateTime(2011, 1,1) * , new DateTime(2010, 1, 1) * , 100 * , Data.typeDonnees.typedonnees.Simulees * , "optionTest" * , new List<double>() {0.5,0.5});*/ this.entree = new Entrees(@"D:\ProjetDotNet\test.txt"); Simulation sim = new Simulation(entree); sim.Lancer(); option = sim.PrixOption; portefeuille = sim.valeurPf; action = sim.PrixAction; RoutedEventArgs temp = new RoutedEventArgs(); object temp2 = new object(); //Window_Loaded(temp2, temp); //Console.WriteLine("la maturity est de"+ maturity); PointShapeLineExample(); }
public void AddEntree(string item) { Entrees.Add(item); }
public void ReturnCorrectFilterByTypes() { Entrees = Menu.Entrees(); //Entrees = Menu.FilterByType(Entrees, CategoriesEmptyList); Sides = Menu.Sides(); Sides = Menu.FilterByType(Sides, CategoriesEmptyList); Drinks = Menu.Drinks(); Drinks = Menu.FilterByType(Drinks, CategoriesEmptyList); Assert.Contains(Menu.FilterByType(Entrees, CategoriesEmptyList), (item) => { return(item is BriarheartBurger); }); Assert.Contains(Entrees, (item) => { return(item is DoubleDraugr); }); Assert.Contains(Entrees, (item) => { return(item is GardenOrcOmelette); }); Assert.Contains(Entrees, (item) => { return(item is PhillyPoacher); }); Assert.Contains(Entrees, (item) => { return(item is SmokehouseSkeleton); }); Assert.Contains(Entrees, (item) => { return(item is ThalmorTriple); }); Assert.Contains(Entrees, (item) => { return(item is ThugsTBone); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Small Aretino Apple Juice")); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Medium Aretino Apple Juice")); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Large Aretino Apple Juice")); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Small Decaf Candlehearth Coffee")); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Medium Decaf Candlehearth Coffee")); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Large Decaf Candlehearth Coffee")); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Small Candlehearth Coffee")); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Medium Candlehearth Coffee")); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Large Candlehearth Coffee")); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Small Markarth Milk")); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Medium Markarth Milk")); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Large Markarth Milk")); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Small Warrior Water")); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Medium Warrior Water")); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Large Warrior Water")); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Small Cherry Sailor Soda")); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Medium Cherry Sailor Soda")); }); Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Large Cherry Sailor Soda")); }); Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Small Dragonborn Waffle Fries")); }); Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Medium Dragonborn Waffle Fries")); }); Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Large Dragonborn Waffle Fries")); }); Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Small Fried Miraak")); }); Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Medium Fried Miraak")); }); Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Large Fried Miraak")); }); Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Small Mad Otar Grits")); }); Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Medium Mad Otar Grits")); }); Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Large Mad Otar Grits")); }); Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Small Vokun Salad")); }); Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Medium Vokun Salad")); }); Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Large Vokun Salad")); }); Entrees = Menu.FilterByType(Entrees, CategoriesNoEntrees); int count = Entrees.Count(); Assert.Equal(0, count); //empty list Sides = Menu.FilterByType(Sides, CategoriesNoSides); count = Sides.Count(); Assert.Equal(0, count); //empty list Drinks = Menu.FilterByType(Drinks, CategoriesNoDrinks); count = Drinks.Count(); Assert.Equal(0, count); //empty list }
public EntreeSelection(Entrees entree) { InitializeComponent(); this.entree = entree; }
/// <summary> /// cunstructor /// </summary> /// <param name="entree"></param> public CretaceousCombo(Entrees entree) { Entree = entree; Side = new Fryceritops(); Drink = new Water(); }
private void filterByIngredient(List <string> ingredient) { List <Entree> tempEntree = new List <Entree>(); List <CretaceousCombo> tempCombo = new List <CretaceousCombo>(); List <Side> tempSide = new List <Side>(); List <Drink> tempDrink = new List <Drink>(); foreach (string i in ingredient) { foreach (Entree entree in Entrees) { if (entree.Ingredients != null && entree.Ingredients.Contains(i)) { tempEntree.Add(entree); } } foreach (CretaceousCombo combo in Combos) { if (combo.ToString() != null && combo.Ingredients.Contains(i)) { tempCombo.Add(combo); } } foreach (Side side in Sides) { if (side.ToString() != null && side.Ingredients.Contains(i)) { tempSide.Add(side); } } foreach (Drink drink in Drinks) { if (drink.ToString() != null && drink.Ingredients.Contains(i)) { tempDrink.Add(drink); } } foreach (Entree entree in tempEntree) { Entrees.Remove(entree); } foreach (CretaceousCombo combo in tempCombo) { Combos.Remove(combo); } foreach (Side side in tempSide) { Sides.Remove(side); } foreach (Drink drink in tempDrink) { Drinks.Remove(drink); } } }
/// <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); } }
/// <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); }
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); } }
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); } }