Example #1
0
        public async void OnLoaded()
        {
            if (!_connectivityService.IsInternetAvailable())
            {
                _loggingService.Warning("Could not load weather data. No Internet connection available.");
                await _dialogService.ShowAsync("Could not load weather data. No Internet connection available.");

                _navigationService.GoTo(AppViews.SnapshotDetails, NavigationParam);
                return;
            }

            IsBusy = true;
            var navParam = (SnapshotDetailsViewNavParams)NavigationParam;
            var snapshot = navParam.LocationSnapshot;

            try
            {
                WeatherForecast = await _weatherDataService.GetWeatherDataForLocationAsync(snapshot);
            }
            catch (Exception ex)
            {
                _loggingService.Warning("Weather API error. This might indicate an incorrect API URI or key. Details: {Ex}", ex);
                await _dialogService.ShowAsync("Weather API error. This might indicate an incorrect API URI or key.");

                _navigationService.GoTo(AppViews.SnapshotDetails, NavigationParam);
                return;
            }
            IsBusy = false;
        }