Permalink
Cannot retrieve contributors at this time
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?
6002CEM_SulaimanMohammed/MainPage.xaml.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
34 lines (28 sloc)
863 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |