Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. public partial class MainPage : ContentPage
  2. {
  3. RestService restService;
  4. public MainPage()
  5. {
  6. InitializeComponent();
  7. restService = new RestService();
  8. }
  9. async void OnButtonClicked(object sender, EventArgs e)
  10. {
  11. if(!string.IsNullOrWhiteSpace(cityEntry.Text))
  12. {
  13. WeatherData weatherData = await restService.GetWeatherDataAsync(GenerateRequestUri(Constants.OpenWeatherMapEndpoint));
  14. BindingContext = weatherData;
  15. }
  16. string GenerateRequestUri(string endpoint)
  17. {
  18. string requestUri = endpoint;
  19. requestUri += $"?q={cityEntry.Text}";
  20. requestUri += "&units=imperial";
  21. requestUri += $"&APPID={Constants.OpenWeatherMapAPIKey}";
  22. return requestUri;
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement