public async static Task <List <DateTime?> > GetAvailableTimesOfStation(Station.Directions direction, int stationId) { List <DateTime?> times = new List <DateTime?>(); try { StorageFile sampleFile = await localFolder.GetFileAsync(direction == 0?StorageRepos.times_sm : StorageRepos.times_ms); string lines_json = await FileIO.ReadTextAsync(sampleFile); var lines = JsonConvert.DeserializeObject <List <Line> >(lines_json); foreach (var line in lines) { if (line.Times[stationId - 1] != null && line.Times[stationId - 1] > DateTime.Now) { times.Add(line.Times[stationId - 1]); } } if (times.Count == 0) { foreach (var line in lines) { if (line.Times[stationId - 1] != null && line.Times[stationId - 1] < DateTime.Now) { times.Add(line.Times[stationId - 1].Value.AddDays(1)); } } } } catch { } return(Task.FromResult(times).Result); }
protected override void OnNavigatedTo(NavigationEventArgs e) { Tuple <Station, Station.Directions> tuple = e.Parameter as Tuple <Station, Station.Directions>; station = tuple.Item1; direction = tuple.Item2; SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; HideSearchBox?.Invoke(); }
public async static Task <List <Station> > GetStations(Station.Directions direction) { try { StorageFile sampleFile = await localFolder.GetFileAsync(direction == Station.Directions.SM?StorageRepos.stations_sm : StorageRepos.stations_ms); string stations_json = await FileIO.ReadTextAsync(sampleFile); return(Task.FromResult(JsonConvert.DeserializeObject <List <Station> >(stations_json)).Result); } catch { return(null); } }
public static Station GetStation(Station.Directions direction, int StationId) { return(GetStations(direction).Result.SingleOrDefault(s => s.Id == StationId)); }
private async Task <List <DateTime?> > GetAvailableTimesOfStation(Station.Directions direction, int stationId) { var times = await LinesRepos.GetAvailableTimesOfStation(direction, stationId); return(Task.FromResult(times).Result); }