public WeatherData(WeatherGetData getData) { this.city = City.GetCityFromID(getData.city.id); foreach (WeatherGetData.List item in getData.list) { this.weatherInfoList.Add(new WeatherInfo(item)); } }
public static async Task <WeatherData> GetWeatherData(int cityID) { string url = CreateURL(cityID); WeatherData resultData = null; using (var client = new HttpClient()) { HttpResponseMessage response = await client.GetAsync(url); if (response.IsSuccessStatusCode) { string data = await response.Content.ReadAsStringAsync(); WeatherGetData getData = JsonConvert.DeserializeObject <WeatherGetData>(data); resultData = new WeatherData(getData); } } return(resultData); }