API.TransitManager.GetSchedule C# (CSharp) Method

GetSchedule() public static method

Returns the bus schedule for the given stop IDs, incorporating the ETA from Connexionz.
public static GetSchedule ( ITransitRepository repository, ITransitClient client, DateTimeOffset currentTime, IEnumerable stopIds ) : Task
repository ITransitRepository
client ITransitClient
currentTime DateTimeOffset
stopIds IEnumerable
return Task
        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;
        }