public async Task <ActionResult> GetStaticData()
        {
            try
            {
                var staticDataJson = await _repository.GetSerializedStaticDataAsync();

                return(Content(staticDataJson, "application/json"));
            }
            catch
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
示例#2
0
        public static async Task <List <FavoriteStopViewModel> > GetFavoritesViewModel(ITransitRepository repository,
                                                                                       ITransitClient client, DateTimeOffset currentTime, IEnumerable <int> stopIds, LatLong?optionalUserLocation)
        {
            var staticData = JsonConvert.DeserializeObject <BusStaticData>(await repository.GetSerializedStaticDataAsync());

            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);
        }
        public static async Task<List<FavoriteStopViewModel>> GetFavoritesViewModel(ITransitRepository repository,
            ITransitClient client, DateTimeOffset currentTime, IEnumerable<int> stopIds, LatLong? optionalUserLocation)
        {
            var staticData = JsonConvert.DeserializeObject<BusStaticData>(await repository.GetSerializedStaticDataAsync());

            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;
        }