private void setCurrentWeatherData(string cityName) { CurrentWeather currentWeather = ApiUtilities.getCurrentWeatherByCityName(cityName); labelDateTime.Text = DisplayTextDataUtility.displayCurrentDateText(); cityLable.Text = DisplayTextDataUtility.displayCity(currentWeather.CityName, currentWeather.Country); //tempLabel.Text = DisplayTextDataUtility.displayTemp(ApiUtilities.convertKelvenToCelcius(currentWeather.Temp)); tempLabel.Text = DisplayTextDataUtility.displayTemp(currentWeather.Temp); //feelsLikeLabel.Text = DisplayTextDataUtility.displayFeelsLike(ApiUtilities.convertKelvenToCelcius(currentWeather.FeelsLike)); feelsLikeLabel.Text = DisplayTextDataUtility.displayFeelsLike(currentWeather.FeelsLike); pressureLabel.Text = DisplayTextDataUtility.displayPressure(currentWeather.Pressure); humidityLabel.Text = DisplayTextDataUtility.displayhumidity(currentWeather.Humidity); windLabel.Text = DisplayTextDataUtility.displaywind(currentWeather.WindSpeed, currentWeather.WindDirection); cloudCoverLabel.Text = DisplayTextDataUtility.displayCloudCover(currentWeather.CloudCover); currentWeatherIconImage.ImageLocation = ApiUtilities.getImageUrl(currentWeather.ImageIcon); }
public static CurrentWeather getCurrentWeatherByCityName(string cityName) { string urlString = Credentials.initialApiSearchByCity + "?q=" + cityName + "&appid=" + Credentials.apiKey; string jsonResponse = ApiUtilities.getJsonStringResponse(urlString); dynamic weatherData = JsonConvert.DeserializeObject(jsonResponse); Console.WriteLine("test : {0}", weatherData.name); CurrentWeather currentWeather = new CurrentWeather(Convert.ToString(weatherData.main.temp), Convert.ToString(weatherData.name), Convert.ToString(weatherData.weather[0].icon), Convert.ToString(weatherData.main.feels_like), Convert.ToString(weatherData.main.pressure), Convert.ToString(weatherData.main.humidity), Convert.ToString(weatherData.wind.speed), Convert.ToString(weatherData.wind.deg), Convert.ToString(weatherData.clouds.all), Convert.ToString(weatherData.sys.country)); return(currentWeather); }