Esempio n. 1
0
        public async void getCityDetails()
        {
            City city = cityVM.getCity();

            using (HttpClient client = new HttpClient())
                try
                {
                    HttpResponseMessage response = await client.GetAsync(API.getForecastURL(city));

                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        Forecast apiForecast = JsonConvert.DeserializeObject <Forecast>(
                            await response.Content.ReadAsStringAsync()
                            );

                        city.UpdateForecast(apiForecast);
                        if (view != null)
                        {
                            view.UpdateChart(); // Updating chart since it does not work with binds
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.Error.Write(ex.StackTrace);
                }
        }