Beispiel #1
0
        public async Task <List <DishesCountPrice> > CalculateIngredients()
        {
            var listOfDishes = await GetListDishes();

            var dishesCountPrice = new List <DishesCountPrice>();

            foreach (var item in listOfDishes)
            {
                var ingredientsList = new List <IngredientsView>();
                foreach (var item2 in item.Ingredients)
                {
                    var dishIngredientById = await _ingredientsRepository.GetDishIngredientsByIngredientsId(item2.IngredientId);

                    var ingredientPrice = new IngredientsView();
                    foreach (var item3 in dishIngredientById)
                    {
                        ingredientPrice.Price = item3.Price;
                    }
                    ingredientsList.Add(ingredientPrice);
                }

                double price          = ingredientsList.Sum(x => x.Price);
                var    dishCountPrice = new DishesCountPrice();
                dishCountPrice.Id    = item.Id;
                dishCountPrice.Name  = item.Name;
                dishCountPrice.Price = price;

                dishesCountPrice.Add(dishCountPrice);
            }
            return(dishesCountPrice);
        }