Esempio n. 1
0
        async void getForecast(string cityName)
        {
            ForecastData forecastData = await restService.GetForecastData(GenerateRequestUri(Constants.OpenWeatherMapForecastEndpoint, cityName));

            PageWeather.ForecastData = forecastData;
            MainPageWeather newWether = new MainPageWeather()
            {
                ForecastData = PageWeather.ForecastData,
                WeatherData  = PageWeather.WeatherData
            };

            BindingContext = newWether;
        }
Esempio n. 2
0
        public async Task <ForecastData> GetForecastData(string query)
        {
            ForecastData forecastData = null;

            try
            {
                var response = await _client.GetAsync(query)
                               .ConfigureAwait(false);

                if (response.IsSuccessStatusCode)
                {
                    var content = await response.Content.ReadAsStringAsync()
                                  .ConfigureAwait(false);

                    forecastData = JsonConvert.DeserializeObject <ForecastData>(content);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\t\terror {0}", ex.Message);
            }
            return(forecastData);
        }