Beispiel #1
0
        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);
        }
Beispiel #2
0
 private void CountSafeIngredientsInFoods() =>
 ApparitionsOfIngredientsWithoutAllergensInFood = _foods
                                                  .SelectMany(food =>
                                                              food.Ingredients
                                                              .Where(ingredient => IngredientsWithoutAllergens.Contains(ingredient))
                                                              .Select(_ => food))
                                                  .Count();
Beispiel #3
0
 private void RefreshIngredientsWithoutAllergens()
 {
     IngredientsWithoutAllergens = IngredientsWithoutAllergens.Distinct().ToList();
     IngredientsWithoutAllergens.RemoveAll(i => IngredientsWithAllergens.Contains(i));
 }