Skip to content
Permalink
fe6569f37b
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
34 lines (28 sloc) 863 Bytes
namespace MauiWeatherForecast;
public partial class MainPage : ContentPage
{
RestService _restService;
public MainPage()
{
InitializeComponent();
_restService = new RestService();
}
async void OnGetWeatherButtonClicked(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(_cityEntry.Text))
{
WeatherData weatherData = await
_restService.
GetWeatherData(GenerateRequestURL(Constants.OpenWeatherMapEndpoint));
BindingContext = weatherData;
}
}
string GenerateRequestURL(string endPoint)
{
string requestUri = endPoint;
requestUri += $"?q={_cityEntry.Text}";
requestUri += "&units=imperial";
requestUri += $"&APPID={Constants.OpenWeatherMapAPIKey}";
return requestUri;
}
}