Exemplo n.º 1
0
        public override async Task InitializeAsync(object navigationData)
        {
            CurrentDate = DateTime.Now;
            IsBusy      = true;

            try
            {
                var weather = await _weatherService.GetWeatherInfoAsync();

                if (weather is WeatherInfo)
                {
                    var weatherInfo = weather as WeatherInfo;
                    Location = weatherInfo.LocationName;
                    Temp     = Math.Round(weatherInfo.Temp).ToString();
                }

                var ridesResult = await _ridesService.GetUserRides();

                MyRides      = new ObservableRangeCollection <Ride>(ridesResult);
                SelectedRide = MyRides.FirstOrDefault();
            }
            catch (Exception ex) when(ex is WebException || ex is HttpRequestException)
            {
                await DialogService.ShowAlertAsync("Communication error", "Error", "Ok");
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Error in: {ex}");
            }

            IsBusy = false;
        }
Exemplo n.º 2
0
        private async Task LoadData()
        {
            IsBusy = true;

            try
            {
                var ridesResult = await _ridesService.GetUserRides();

                MyRides = new ObservableRangeCollection <Ride>(ridesResult);
            }
            catch (Exception ex) when(ex is WebException || ex is HttpRequestException)
            {
                await DialogService.ShowAlertAsync("Communication error", "Error", "Ok");
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Error in: {ex}");
            }

            IsBusy = false;
        }