private void SearchForProperties() { Locations = new List <LocationViewModel>(); IsLoading = true; UserMessage = null; _searchItem.FindProperties(_propertyDataSource, 1, response => { if (response is PropertyListingsResult) { var propertiesResponse = (PropertyListingsResult)response; if (propertiesResponse.Data.Count == 0) { UserMessage = "There were no properties found for the given location."; } else { var listingsResponse = (PropertyListingsResult)response; _state.AddSearchToRecent(new RecentSearch(_searchItem, listingsResponse.TotalResult, this)); RecentSearches = _state.RecentSearches.ToList(); var presenter = new SearchResultsViewModel(_navigationService, _state, listingsResponse, _searchItem, _propertyDataSource); _navigationService.PushViewModel(presenter); } } else if (response is PropertyLocationsResult) { RecentSearches = new List <RecentSearch>(); // TODO - this is yucky! Locations = ((PropertyLocationsResult)response).Data .Select(location => new LocationViewModel(this, location)) .ToList(); } else { UserMessage = "The location given was not recognised."; } IsLoading = false; }, error => { UserMessage = "An error occurred while searching. Please check your network connection and try again."; IsLoading = false; }); }
private void SearchForProperties() { Locations = new List<LocationViewModel>(); IsLoading = true; UserMessage = null; _searchItem.FindProperties(_propertyDataSource, 1, response => { if (response is PropertyListingsResult) { var propertiesResponse = (PropertyListingsResult)response; if (propertiesResponse.Data.Count == 0) { UserMessage = "There were no properties found for the given location."; } else { var listingsResponse = (PropertyListingsResult)response; _state.AddSearchToRecent(new RecentSearch(_searchItem, listingsResponse.TotalResult, this)); RecentSearches = _state.RecentSearches.ToList(); var presenter = new SearchResultsViewModel(_navigationService, _state, listingsResponse, _searchItem, _propertyDataSource); _navigationService.PushViewModel(presenter); } } else if (response is PropertyLocationsResult) { RecentSearches = new List<RecentSearch>(); // TODO - this is yucky! Locations = ((PropertyLocationsResult)response).Data .Select(location => new LocationViewModel(this, location)) .ToList(); } else { UserMessage = "The location given was not recognised."; } IsLoading = false; }, error => { UserMessage = "An error occurred while searching. Please check your network connection and try again."; IsLoading = false; }); }