コード例 #1
0
ファイル: Menu.cshtml.cs プロジェクト: brendenlevi/dino-diner
        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);
                }
            }
        }