private void StoreFoodIngredientsWithoutAllergens(List <Food> food) { var ingredientsThatDontContainGivenAllergen = food .SelectMany(p => p.Ingredients) .GroupBy(p => p) .Select(p => p.Key) .Where(p => !IngredientsWithAllergens.Contains(p)) .ToList(); IngredientsWithoutAllergens.AddRange(ingredientsThatDontContainGivenAllergen); }
private void RefreshIngredientsWithoutAllergens() { IngredientsWithoutAllergens = IngredientsWithoutAllergens.Distinct().ToList(); IngredientsWithoutAllergens.RemoveAll(i => IngredientsWithAllergens.Contains(i)); }