public static async Task<BusArrivalEstimates> GetEtas(ITransitRepository repository, ITransitClient client, IEnumerable<int> stopIds)
{
var toPlatformTag = await repository.GetPlatformTagsAsync();
Func<int, Task<Tuple<int, ConnexionzPlatformET>>> getEtaIfTagExists =
async id => Tuple.Create(id, toPlatformTag.ContainsKey(id) ? await client.GetEta(toPlatformTag[id]) : null);
var tasks = stopIds.Select(getEtaIfTagExists);
var results = await Task.WhenAll(tasks);
return results.ToDictionary(eta => eta.Item1,
eta => eta.Item2?.RouteEstimatedArrivals
?.ToDictionary(routeEta => routeEta.RouteNo,
routeEta => routeEta.EstimatedArrivalTime)
?? new Dictionary<string, List<int>>());
}