public static async Task<ClientBusSchedule> GetSchedule(ITransitRepository repository, ITransitClient client, DateTimeOffset currentTime, IEnumerable<int> stopIds)
{
var schedulesTask = repository.GetScheduleAsync();
var estimatesTask = GetEtas(repository, client, stopIds);
var schedule = await schedulesTask;
var estimates = await estimatesTask;
Func<int, Dictionary<string, List<BusArrivalTime>>> makePlatformSchedule = platformNo =>
schedule[platformNo].ToDictionary(routeSchedule => routeSchedule.RouteNo,
routeSchedule => InterleaveRouteScheduleAndEstimates(
routeSchedule,
estimates.ContainsKey(platformNo)
? estimates[platformNo]
: new Dictionary<string, List<int>>(),
currentTime));
var todaySchedule = stopIds.Where(schedule.ContainsKey)
.ToDictionary(platformNo => platformNo, makePlatformSchedule);
return todaySchedule;
}