Esempio n. 1
0
 public string GetLocationName(string city)
 {
     if (localWeather.LocationName == null || localWeather.LocationName.ToUpper() != city.ToUpper())
     {
         localWeather = GetWeather(city);
     }
     if (found)
     {
         string loca = localWeather.LocationName;
         return(loca);
     }
     else
     {
         return("Not found");
     }
 }
Esempio n. 2
0
 public double GetTemperatureC(string city)
 {
     if (localWeather.LocationName == null || localWeather.LocationName.ToUpper() != city.ToUpper())
     {
         localWeather = GetWeather(city);
     }
     if (found)
     {
         double temp = Math.Round(localWeather.MainData.Temperature - 272.15);
         return(temp);
     }
     else
     {
         return(0);
     }
 }
Esempio n. 3
0
 public double GetWindSpeed(string city)
 {
     if (localWeather.LocationName == null || localWeather.LocationName.ToUpper() != city.ToUpper())
     {
         localWeather = GetWeather(city);
     }
     if (found)
     {
         double temp = Math.Round(localWeather.Wind.Speed);
         return(temp);
     }
     else
     {
         return(0);
     }
 }
Esempio n. 4
0
        //==========================================================================

        static async Task <CurrentWeather> GetWeatherAsync(string path)
        {
            path += "&APPID=52087b841a0e19eae02720bc08ef0b5b";
            HttpResponseMessage response = await client.GetAsync(path);

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

                localWeather = JsonConvert.DeserializeObject <CurrentWeather>(data);
                found        = true;
            }
            else
            {
                found = false;
            }
            return(localWeather);
        }