public async Task Search(string searchTownName) { if (WeatherList == null || SelectedTown == null) { return; } var searchResult = await _dataAccess.SearchTownWeather(searchTownName); if (searchResult != null) { var townFromList = WeatherList.FirstOrDefault(n => n.TownName == searchResult.TownName); if (townFromList == null) { WeatherList.Add(searchResult); _townsRepository.SaveTownsList(townsList); townFromList = WeatherList.FirstOrDefault(n => n.TownName == searchResult.TownName); } SelectedTown = townFromList; TownName = townFromList.TownName; CurrentWeather = townFromList.CurrentWeather; WeatherToday = townFromList.WeatherToday; } else { MessageBox.Show(SettingsRes.text_TownNotFound); } }
public void RemoveTown() { WeatherList.Remove(SelectedTown); SelectedTown = WeatherList.FirstOrDefault(); UpdateWeather(SelectedTown); _townsRepository.SaveTownsList(townsList); }