Esempio n. 1
0
        public async Task UpdateCityWeather(CityViewModel cityVM)
        {
            City city = cityVM.getCity();

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

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

                        city.UpdateWeather(apiWeather);
                    }
                }
                catch (Exception ex)
                {
                    Console.Error.Write(ex.StackTrace);
                }
            return;
        }
Esempio n. 2
0
 public DetailedCityViewModel(CityViewModel cityVM)
 {
     this.cityVM = cityVM;
 }
Esempio n. 3
0
        public async void AddCity(CityViewModel city)
        {
            await UpdateCityWeather(city);

            Cities.Add(city);
        }