private string GenerateRequestUriWithLatLon(string endpoint, Location location) { string lat = location.lat.ToString(); string lon = location.lon.ToString(); var requestUri = endpoint; requestUri += $"?lat={lat}&lon={lon}"; requestUri += "&units=metric"; requestUri += $"&APPID={API_Data.OpenWeatherMapAPIKey}"; return(requestUri); }
public async Task ShowCurrentWeatherAsync() { Location loc = GetCurrentLocation(); currentweather = await GetWeatherWithLatLonAsync(loc); area = await GetCurrentArea(loc); SetWeather(); OnPropertyChanged("area"); }
public async Task <WeatherData> GetWeatherWithLatLonAsync(Location location) { IsLoading = true; OnPropertyChanged("IsLoading"); currentweather = await restservice.GetWeatherData(GenerateRequestUriWithLatLon(API_Data.OpenWeatherMapEndpoint, location)); if (currentweather != null) { return(currentweather); } else { throw (new ArgumentNullException()); } }
private async Task <string> GetCurrentArea(Location loc) { return(await restservice.ResolveAreaAsync(loc)); }