internal async void NavigateToDetails(StationShort selectedStation) { this.resultStations.Clear(); this.InProgress = true; try { Location locator = new Location(); Point myLocation = await locator.CurrentPosition; StationFullModel stationModel = await GetStation(selectedStation.StationId, myLocation); string model = JsonConvert.SerializeObject(stationModel.Stations.First()); Frame rootFrame = Window.Current.Content as Frame; this.InProgress = false; if (rootFrame != null) { rootFrame.Navigate(typeof(DetailsPage), model); } } catch (Exception e) { if (e.GetType() == typeof(UnauthorizedAccessException)) { Notification.ShowMessage("Sorry! Couldn't get your position! No relevant information can be provided! Please go to Settings - Permissions, allow usage of location and then press Refresh button."); } else { Notification.ShowMessage("Sorry! Could not load data! Try to reconnect to Internet and then press Refresh!"); } } }
private async void GetData() { if (this.nearestStations != null) { this.nearestStations.Clear(); } this.InProgress = true; Location locator = new Location(); this.settings = new UserSettings(); StationFullModel stationsData = new StationFullModel(); try { this.location = await locator.CurrentPosition; stationsData = await DataPersister.GetNearestStations(this.location, this.settings.MaxNearStations); this.NearestStations = stationsData.Stations; if (stationsData.Timespan != 0) { DateTime dateTime = Conversion.UnixTimeStampToDateTime(stationsData.Timespan); this.SetBranding(dateTime); } } catch (Exception e) { if (e.GetType() == typeof(UnauthorizedAccessException)) { Notification.ShowMessage("Sorry! Couldn't get your position! No relevant information can be provided! Please go to Settings - Permissions, allow usage of location and then press Refresh button."); } else { Notification.ShowMessage("Sorry! Could not load data! Try to reconnect to Internet and then press Refresh!"); } } this.InProgress = false; }