Ejemplo n.º 1
0
        public static async Task <WeatherNow> GetWeatherNow(string cityName)
        {
            using (var client = new HttpClient())
            {
                WeatherNow weatherNow = null;
                try
                {
                    var response =
                        await client.GetAsync(GenerateRequestUri(Constants.OpenWeatherMapWeatherEndpoint, cityName));

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

                        weatherNow = JsonConvert.DeserializeObject <WeatherNow>(content);
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("\t\tERROR {0}", ex.Message);
                }

                return(weatherNow);
            }
        }
Ejemplo n.º 2
0
 public void Update(WeatherNow wn)
 {
     city    = wn.name;
     country = wn.sys.country;
     city_id = wn.id;
 }