/// <summary> /// Function to get current weather and update the elements. Comments work in case /// you want to keep that info, but at least in México is mostly empty /// </summary> protected void updateWeather() { try { //gets clients georeference string latitude = this.latitude.Text; string longitude = this.longitude.Text; string unit = this.dwlMeasureUnit.SelectedValue; //gets current weather via OpenWeather API OpenWeatherReponse weatherResponse = OpenWeather.GetOpenWeatherObjectAsync(latitude, longitude); //if (weatherResponse.Main.FeelsLike != 0) //{ // feels_like.InnerText = (weatherResponse.Main.FeelsLike - 273.15).ToString() + " °C"; //} //else //{ // feels_like.InnerText = "No Data"; //} //humidity.InnerText = (weatherResponse.Main.Humidity).ToString(); //pressure.InnerText = (weatherResponse.Main.Pressure).ToString(); //Updates the aspx elements if (weatherResponse.Main.Temp != 0) { temp.InnerText = GeneralFunctions.convertTemperatureAndFormat(weatherResponse.Main.Temp, unit); //(weatherResponse.Main.Temp - 273.15).ToString() + " °C"; } else { temp.InnerText = "No Data"; } //if (weatherResponse.Main.TempMax != 0) //{ // temp_max.InnerText = GeneralFunctions.convertTemperature(weatherResponse.Main.TempMax, unit); //(weatherResponse.Main.TempMax - 273.15).ToString() + " °C"; //} //else //{ // temp_max.InnerText = "No Data"; //} //if (weatherResponse.Main.TempMin != 0) //{ // temp_min.InnerText = GeneralFunctions.convertTemperature(weatherResponse.Main.TempMin, unit); //(weatherResponse.Main.TempMin - 273.15).ToString() + " °C"; //} //else //{ // temp_min.InnerText = "No Data"; //} name.InnerText = weatherResponse.Name; CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; weatherDescription.InnerText = textInfo.ToTitleCase(weatherResponse.Weather[0].Description); weatherIcon.Src = "http://openweathermap.org/img/wn/" + weatherResponse.Weather[0].Icon + ".png"; country.InnerText = weatherResponse.Sys.Country; } catch (Exception e) { throw e; } }