public async Task <HttpStatusResultStatistics> GetStatistics(Filters filters) { Task <IEnumerable <HttpStatusResultDto> > results; Task <IEnumerable <HttpStatusResultDto> > slowestRequests; Task <IEnumerable <HttpStatusResultDto> > fastestRequests; switch (filters.CollationType) { case CollationType.Requests: results = _requestResultRepository.GetRequests(filters); slowestRequests = _requestResultRepository.GetSlowestRequests(filters); fastestRequests = _requestResultRepository.GetFastestRequests(filters); break; case CollationType.Tests: results = _testResultRepository.GetTests(filters); slowestRequests = _testResultRepository.GetSlowestTests(filters); fastestRequests = _testResultRepository.GetFastestTests(filters); break; default: throw new ArgumentOutOfRangeException(); } await Task.WhenAll(results, slowestRequests, fastestRequests); return(_statisticsFactory.Create(filters, results.Result.ToList(), slowestRequests.Result, fastestRequests.Result)); }