public async Task <WeatherResult> GetWeatherProperties(string cityWeather) { WeatherResult weatherResult = null; var temp = await httpClient.GetAsync(cityWeather); if (temp.IsSuccessStatusCode) { var responseData = await temp.Content.ReadAsStringAsync(); weatherResult = JsonConvert.DeserializeObject <WeatherResult>(responseData); } return(weatherResult); }
async void OnButtonWeatherClicked(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(cityEntry.Text)) { var city = cityEntry.Text; WeatherResult weatherResult = await httpClient.GetWeatherProperties(API_LINK + city + "&units=metric&APPID=" + API_KEY); BindingContext = weatherResult; WeatherIcon.Source = "http://openweathermap.org/img/wn/" + weatherResult._weather[0]._icon + "@2x.png"; if (gridWeather.IsVisible == false) { gridWeather.IsVisible = true; } if (gridForecast.IsVisible == true) { gridForecast.IsVisible = false; } } }