Beispiel #1
0
        public async Task <string> GetWeatherInfo(string location)
        {
            var currentDate = DateTime.Now.ToString("yyyy/MM/dd");

            //Step 1: Get location info by location name
            var locationInfo = await _client.GetResponseAsync <List <LocationInfo> >($"location/search/?query={location}");

            var locData = locationInfo[0];

            //Step 2: Get weather data by location long and lat
            var weatherInfo = await _client.GetResponseAsync <List <WeatherInfo> >($"location/{locData.woeid}/{currentDate}/");

            return($"Current weather in {location} is {weatherInfo.First().the_temp}");
        }
Beispiel #2
0
        public async Task <string> GetWeatherInfo(string location)
        {
            var weatherInfo = await _client.GetResponseAsync <ApixuWeatherInfo>($"current.json?key=cc73d8f649fb445e895154453181509&q={location}");

            return($"Current weather in {location} is {weatherInfo.current.temp_c}");
        }