Пример #1
0
        public IList <Food> CheckAvailableSideDishes(int foodId)
        {
            var recepies = _foodQueryRepository.Query(new FoodQueryModel()
            {
                Id = foodId
            })
                           .Map(x => x.Items.FirstOrNone())
                           .Map(z =>
                                z.Map(x => _recipeQueryRepository.Query(new RecipeQueryModel()
            {
                MainCourseId = x.Id
            }))
                                .Reduce(PagingResult <Recipe> .Empty()))
                           .Map(x => x.Items)
                           .Reduce(_ => new List <Recipe>());

            return(recepies.SelectMany(x => x.SideDish).ToList());
        }
Пример #2
0
        /// <summary>
        /// Finds <see cref="Food"/> in database based on sheet data
        /// </summary>
        /// <param name="restaurant">Restaurant to get food for</param>
        /// <param name="dailyMenufoods">Food list from sheet</param>
        /// <returns>Food list from database</returns>
        private List <Food> FoodsFromDB(Restaurant restaurant, List <Food> dailyMenufoods)
        {
            var results = _foodQueryRepository.Query(new FoodQueryModel()
            {
                RestaurantId = restaurant.Id
            })
                          .Map(x =>
            {
                List <Food> result = new List <Food>();
                foreach (var food in dailyMenufoods)
                {
                    result.Add(x.Items.First(f => f.Name == food.Name));
                }

                return(result);
            })
                          .Reduce(_ => new List <Food>());

            return(results);
        }