private async Task Run() { Weather.Text = ""; var city = "Lincoln, NE"; var client = new OpenWeatherMapClient(); var weather = await client.GetCurrentWeatherByCityAsync(city); Weather.Text += $"Temp: {weather?.Main?.Temperature}\n"; Weather.Text += $"Low: {weather?.Main?.MinTemperature}\n"; Weather.Text += $"High: {weather?.Main?.MaxTemperature}\n"; Icon.Source = weather.WeatherIconUrl(); }
public async Task <IActionResult> Weather(string city = "Aarhus, DK") { var client = new OpenWeatherMapClient(); var weather = await client.GetCurrentWeatherByCityAsync(city); if (weather is null) { return(Content($"No weather for {city}")); } var message = $"<h2>{city}</h2>" + $"<img src=\"{weather.FirstCondition?.IconUrl}\" /><br>" + $"Condition: {weather.FirstCondition?.Description}<br>" + $"Temp: {weather.Main?.Temperature}<br>" + $"Low: {weather.Main?.MinTemperature}<br>" + $"High: {weather.Main?.MaxTemperature}<br>" + $"Humidity: {weather.Main?.Humidity}%<br>"; return(Content(message, "text/html")); }