/// <summary>
        /// Returns the bus schedule for the given stop IDs, incorporating the ETA from Connexionz.
        /// </summary>
        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;
            
            // Holy nested dictionaries batman
            var todaySchedule = stopIds.Where(schedule.ContainsKey)
                                       .ToDictionary(platformNo => platformNo,
                                                     platformNo => schedule[platformNo]
                .ToDictionary(routeSchedule => routeSchedule.RouteNo,
                              routeSchedule => InterleaveRouteScheduleAndEstimates(routeSchedule, estimates.ContainsKey(platformNo) ? estimates[platformNo] : new Dictionary<string, List<int>>(), currentTime)));

            return todaySchedule;
        }
Beispiel #2
0
        /// <summary>
        /// Returns the bus schedule for the given stop IDs, incorporating the ETA from Connexionz.
        /// </summary>
        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;

            // Holy nested dictionaries batman
            var todaySchedule = stopIds.Where(schedule.ContainsKey)
                                .ToDictionary(platformNo => platformNo,
                                              platformNo => schedule[platformNo]
                                              .ToDictionary(routeSchedule => routeSchedule.RouteNo,
                                                            routeSchedule => InterleaveRouteScheduleAndEstimates(routeSchedule, estimates.ContainsKey(platformNo) ? estimates[platformNo] : new Dictionary <string, List <int> >(), currentTime)));

            return(todaySchedule);
        }