/// <summary>
        /// Gets a user friendly arrivals summary for the requested stops.
        /// Returns a dictionary which takes a stop ID and returns the list of route arrival summaries (used to populate a table).
        /// </summary>
        public static async Task <Dictionary <int, List <RouteArrivalsSummary> > > GetArrivalsSummary(ITransitRepository repository, ITransitClient client, DateTimeOffset currentTime, IEnumerable <int> stopIds)
        {
            var schedule = await GetSchedule(repository, client, currentTime, stopIds);

            var staticData = await repository.GetStaticDataAsync();

            var matchingStopIds   = stopIds.Where(staticData.Stops.ContainsKey);
            var arrivalsSummaries = matchingStopIds.ToDictionary(stopId => stopId,
                                                                 stopId => ToRouteArrivalsSummaries(staticData.Stops[stopId].RouteNames, schedule[stopId], currentTime));

            return(arrivalsSummaries);
        }
        public static async Task <List <FavoriteStopViewModel> > GetFavoritesViewModel(ITransitRepository repository,
                                                                                       ITransitClient client, DateTimeOffset currentTime, IEnumerable <int> stopIds, LatLong?optionalUserLocation)
        {
            var staticData = await repository.GetStaticDataAsync();

            var favoriteStops = GetFavoriteStops(staticData, stopIds, optionalUserLocation);

            var scheduleTask = GetSchedule(repository, client, currentTime, favoriteStops.Select(f => f.Id));

            var schedule = await scheduleTask;

            var result = favoriteStops.Select(favorite => ToViewModel(favorite, staticData, schedule, currentTime))
                         .ToList();

            return(result);
        }
        /// <summary>
        /// Gets a user friendly arrivals summary for the requested stops.
        /// Returns a dictionary which takes a stop ID and returns the list of route arrival summaries (used to populate a table).
        /// </summary>
        public static async Task<Dictionary<int, List<RouteArrivalsSummary>>> GetArrivalsSummary(ITransitRepository repository, ITransitClient client, DateTimeOffset currentTime, IEnumerable<int> stopIds)
        {
            var schedule = await GetSchedule(repository, client, currentTime, stopIds);
            var staticData = await repository.GetStaticDataAsync();

            var matchingStopIds = stopIds.Where(staticData.Stops.ContainsKey);
            var arrivalsSummaries = matchingStopIds.ToDictionary(stopId => stopId,
                stopId => ToRouteArrivalsSummaries(staticData.Stops[stopId].RouteNames, schedule[stopId], currentTime));
            return arrivalsSummaries;
        }
        public static async Task<List<FavoriteStopViewModel>> GetFavoritesViewModel(ITransitRepository repository,
            ITransitClient client, DateTimeOffset currentTime, IEnumerable<int> stopIds, LatLong? optionalUserLocation)
        {
            var staticData = await repository.GetStaticDataAsync();

            var favoriteStops = GetFavoriteStops(staticData, stopIds, optionalUserLocation);

            var scheduleTask = GetSchedule(repository, client, currentTime, favoriteStops.Select(f => f.Id));

            var schedule = await scheduleTask;

            var result = favoriteStops.Select(favorite => ToViewModel(favorite, staticData, schedule, currentTime))
                                      .ToList();

            return result;
        }