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; }
public DetailedCityViewModel(CityViewModel cityVM) { this.cityVM = cityVM; }
public async void AddCity(CityViewModel city) { await UpdateCityWeather(city); Cities.Add(city); }