public AggregatedIngredientsDetailsDto Handle(GetAggregatedIngredientsDetailsQuery query)
        {
            var ingredients      = _ingredientRepository.GetByIds(query.GetIds());
            var ingredientsGrams = ingredients
                                   .Select(x => new IngredientGrams(x, query.GetGramsForIngredient(x.Id.Value)));
            var ingredientsGramsCollection = new IngredientsGramsCollection(ingredientsGrams);

            return(AggregatedIngredientsDetailsDto.FromIngredientsGramsCollection(ingredientsGramsCollection));
        }
Пример #2
0
        public static AggregatedIngredientsDetailsDto FromIngredientsGramsCollection(
            IngredientsGramsCollection ingredientsGramsCollection)
        {
            var calories              = ingredientsGramsCollection.CalculateCalories();
            var allergens             = ingredientsGramsCollection.GetAllergens();
            var requirements          = ingredientsGramsCollection.GetRequirements();
            var macroNutrientQuantity = ingredientsGramsCollection.GetMacroNutrientQuantity();

            return(new AggregatedIngredientsDetailsDto(calories, allergens, requirements, macroNutrientQuantity));
        }