/// <summary> /// Make OpenWeather API Call to get location coordinates from search string /// </summary> public async void SetLocation() { try { await LocationSearch.SearchLocations(); } catch (Exception) { var E = new ErrorMessage("An error occurred whilst searching for location"); DisplayErrors.Add(E); } if (LocationSearch.SearchResults.Count == 0) { var E = new ErrorMessage($"Could not find a Match for {LocationSearch.SearchText}"); DisplayErrors.Clear(); DisplayErrors.Add(E); } else { // results found DisplayErrors.Clear(); Location = LocationSearch.SearchResults[0]; GetForecast(); } }
public WeatherForecastViewModel(AppSecrets appSecrets, Location location) { OpenWeather = new OpenWeather(appSecrets.ApiKey); // use the Logger event LocationSearch = new LocationSearch(OpenWeather); Location = location; InitCommands(); }