Skip to content
Permalink
2de335e8aa
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
50 lines (42 sloc) 1.24 KB
namespace WeatherApp;
public partial class MainPage : ContentPage
{
RestService _restService;
public MainPage()
{
InitializeComponent();
_restService = new RestService();
BindingContext = new WeatherData();
}
async void OnGetWeatherButtonClicked(object sender,EventArgs e) {
if (!string.IsNullOrWhiteSpace(_cityEntry.Text))
{
var _BindingContext = BindingContext as WeatherData;
if (!_BindingContext.IsEnabled)
{
DisplayAlert("", "Please Wait", "close");
return;
}
_BindingContext.IsEnabled = false;
WeatherData weatherData = await
_restService.
GetWeatherData(GenerateRequestURL(Api.Endpoint));
weatherData.IsEnabled = true;
BindingContext = weatherData;
}
else
{
DisplayAlert("", "Please enter the city","close");
}
}
string GenerateRequestURL(string endPoint) {
string requestUri = endPoint;
requestUri += $"?query={_cityEntry.Text}";
requestUri += $"&unit={Api.unit}";
requestUri += $"&version=today";
requestUri += $"&language={Api.Language}";
requestUri += $"&appid={Api.AppId}";
requestUri += $"&appsecret={Api.Appsecret}";
return requestUri;
}
}