public async Task <IEnumerable <HospitalSuggestion> > ListSuggestionsAsync(int take) { var waitingTime = await GetHospitalsWatingTimeAsync(); var hospitalTasks = waitingTime.ToList() .OrderBy(x => x.Value) .Take(take) .Select(x => x.Key) .Select(async x => await _hospitalRepository.GetAsync(x)); var hospitals = await Task.WhenAll(hospitalTasks); return(hospitals.Select(x => new HospitalSuggestion { Id = x.Id, Name = x.Name, WaitTime = waitingTime[x.Id] })); }