public static List <AllergenBoolCombination> CombineAllergenAndBool(Dish dish) { DataAccess da = new DataAccess(); List <AllergenBoolCombination> outputList = new List <AllergenBoolCombination>(); List <Allergen> dishAllergens = da.GetAllergensBasedOnDishId(dish); foreach (Allergen allergen in da.GetAllergens()) { AllergenBoolCombination allergenBoolCombination = new AllergenBoolCombination(); allergenBoolCombination.allergen = allergen; if (dishAllergens.Contains(allergen)) { allergenBoolCombination.hasAllergen = true; } else { allergenBoolCombination.hasAllergen = false; } outputList.Add(allergenBoolCombination); } return(outputList); }
public static List <AllergenBoolCombination> CombineAllergenAndBool(MenuManager menuManager, List <Allergen> allergens) { List <AllergenBoolCombination> outputList = new List <AllergenBoolCombination>(); foreach (Allergen allergen in menuManager.allAllergens) { AllergenBoolCombination allergenBoolCombination = new AllergenBoolCombination(); allergenBoolCombination.allergen = allergen; if (allergens.Contains(allergen)) { allergenBoolCombination.hasAllergen = true; } else { allergenBoolCombination.hasAllergen = false; } outputList.Add(allergenBoolCombination); } return(outputList); }