private void DoLoadMore() { _pageNumber++; IsBusy = true; Title = "Loading..."; _searchItem.FindProperties(_dataSource, _pageNumber, response => { var result = response as PropertyListingsResult; if (result != null) { int totalPages = result.TotalPages; foreach (var property in result.Data) { Properties.Add(new PropertyViewModel(_stateFactory, property)); } RaisePropertyChanged(() => PropertiesLoaded); TotalResults = result.TotalResult; IsMoreAvailable = _pageNumber < totalPages; IsBusy = false; Title = string.Format("{0} of {1} matches", PropertiesLoaded, TotalResults); } }, error => { IsBusy = false; }); }
private void SearchForProperties() { IsBusy = true; Message = string.Empty; _searchItem.FindProperties(_dataSource, 1, response => { if (response is PropertyListingsResult) { var propertiesResponse = (PropertyListingsResult)response; if (propertiesResponse.Data.Count == 0) { Message = "There were no properties found for the given location."; } else { var listingsResponse = (PropertyListingsResult)response; _state.AddSearchToRecent(new RecentSearch(_searchItem, listingsResponse.TotalResult)); LoadRecentSearches(); if (_searchItem is PlainTextSearchItem) { ShowViewModel <SearchResultsViewModel>(_searchItem as PlainTextSearchItem); } else { var item = _searchItem as GeoLocationSearchItem; ShowViewModel <SearchResultsViewModel>(item.Location); } //Need to navigate here //_view.DisplayRecentSearches(_state.RecentSearches); //var presenter = new SearchResultsPresenter(_navigationService, _state, listingsResponse, // _searchItem, _propertyDataSource); //_navigationService.PushPresenter(presenter); ShowSelectLocation = false; } } else if (response is PropertyLocationsResult) { var results = ((PropertyLocationsResult)response).Data; SuggestedLocations.Clear(); foreach (Location location in results) { SuggestedLocations.Add(location); } ShowSelectLocation = true; } else { Message = "The location given was not recognised."; } IsBusy = false; }, error => { Message = "An error occurred while searching. Please check your network connection and try again."; IsBusy = false; }); }