Exemple #1
0
 public WeatherViewModel()
 {
     accuWeatherCurrent  = new AccuWeatherCurrent();
     accuWeather5Day     = new AccuWeather5Day();
     accuWeatherLocation = new AccuWeatherLocation();
     Cities         = new ObservableCollection <AccuWeatherLocation>();
     RefreshCommand = new RefreshCommand(this);
 }
Exemple #2
0
        public static async Task <AccuWeatherCurrent> GetAccuWeatherCurrentInfoAsync(string LocationKey) // 307297 Barcelona
        {
            AccuWeatherCurrent result = new AccuWeatherCurrent();
            string             url    = string.Format(API_ACCUWEATHERCURRENT, LocationKey, API_KEY);

            using (HttpClient client = new HttpClient())
            {
                var resultado = await client.GetAsync(url);

                if (resultado.IsSuccessStatusCode)
                {
                    string content = await resultado.Content.ReadAsStringAsync();

                    result = JsonConvert.DeserializeObject <List <AccuWeatherCurrent> >(content).FirstOrDefault();
                }
            }
            return(result);
        }