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); } }
public FoodDto GetFood(int Id) { var food = _foodRepositories.GetFood(Id); return(FoodDto.ToFoodDto(food)); }