Exemple #1
0
        public static async Task <ListForecast> getDataFromServiceForecast(string queryStringForecast)
        {
            HttpClient client   = new HttpClient();
            var        response = await client.GetAsync(queryStringForecast);



            string       json         = response.Content.ReadAsStringAsync().Result;
            ListForecast weatherData2 = JsonConvert.DeserializeObject <ListForecast>(json);

            return(weatherData2);
        }
Exemple #2
0
        public static async Task <Weather2> GetWeatherForecast(string zipcode)
        {
            string queryString         = WEATHER_API + zipcode + "&appid=" + KEY;
            string queryStringForecast = WEATHER_API_Forecast + zipcode + "&appid=" + KEY;

            WeatherData results = await DataService.getDataFromService(queryString).ConfigureAwait(false);

            ListForecast result = await DataService.getDataFromServiceForecast(queryStringForecast).ConfigureAwait(false);

            if (result != null && results.cod == 200)
            {
                Weather2 weather2 = new Weather2();
                weather2.Temperature2 = result.main.temp - KtoC;
                weather2.Img2         = string.Concat("http://openweathermap.org/img/w/", result.weather[0].icon, ".png");
                weather2.Date         = result.dt_txt;
                return(weather2);
            }
            else
            {
                return(null);
            }
        }