Exemple #1
0
        private void View_LoadMoreClicked(object sender, EventArgs e)
        {
            _pageNumber++;
            _view.IsLoading = true;

            _searchItem.FindProperties(_dataSource, _pageNumber, response =>
            {
                if (response is PropertyListingsResult)
                {
                    _properties.AddRange(((PropertyListingsResult)response).Data);
                    _view.SetSearchResults(_totalResult, _pageNumber, _totalPages, _properties, _searchItem.DisplayText);
                    _view.SetLoadMoreVisible(_pageNumber < _totalPages);
                    _view.IsLoading = false;
                }
            }, error =>
            {
                _view.IsLoading = false;
            });
        }
        private void SearchForProperties()
        {
            _view.IsLoading = true;

            _view.SetMessage(null);

            _searchItem.FindProperties(_propertyDataSource, 1, response =>
            {
                if (response is PropertyListingsResult)
                {
                    var propertiesResponse = (PropertyListingsResult)response;
                    if (propertiesResponse.Data.Count == 0)
                    {
                        _view.SetMessage("There were no properties found for the given location.");
                    }
                    else
                    {
                        var listingsResponse = (PropertyListingsResult)response;
                        _state.AddSearchToRecent(new RecentSearch(_searchItem, listingsResponse.TotalResult));
                        _view.DisplayRecentSearches(_state.RecentSearches);
                        var presenter = new SearchResultsPresenter(_navigationService, _state, listingsResponse,
                                                                   _searchItem, _propertyDataSource);
                        _navigationService.PushPresenter(presenter);
                    }
                }
                else if (response is PropertyLocationsResult)
                {
                    _view.DisplayRecentSearches(null);
                    _view.DisplaySuggestedLocations(((PropertyLocationsResult)response).Data);
                }
                else
                {
                    _view.SetMessage("The location given was not recognised.");
                }

                _view.IsLoading = false;
            }, error =>
            {
                _view.SetMessage("An error occurred while searching. Please check your network connection and try again.");
                _view.IsLoading = false;
            });
        }