예제 #1
0
        private string GetFoodName(int primaryId, IEnumerable <int> additionalIds)
        {
            var primaryFood     = _foodRepositories.GetFood(primaryId);
            var additionalFoods = _foodRepositories.GetFood(additionalIds);

            if (additionalFoods.Any())
            {
                var foods = additionalIds
                            .Select(x => additionalFoods.FirstOrDefault(y => y.Id == x))
                            .GroupBy(x => x.FoodName)
                            .Select(g =>
                {
                    if (g.Count() > 1)
                    {
                        return($"{g.Key}*{g.Count()}");
                    }
                    return(g.Key);
                })
                ;
                additionalFoods.Select(x => x.FoodName);
                return($"{primaryFood.FoodName}({string.Join(',', foods)})");
            }
            else
            {
                return(primaryFood.FoodName);
            }
        }
예제 #2
0
        public FoodDto GetFood(int Id)
        {
            var food = _foodRepositories.GetFood(Id);

            return(FoodDto.ToFoodDto(food));
        }