public virtual void CanGetSearchTotal() { var searchRequest = new AgencySearchRequest(); searchRequest.AgencyQuery = "IT "; int results = _agencyRepository.GetSearchTotal(searchRequest); Assert.That(results == 1); }
public SearchResultFormViewModel <AgencyDto, AgencySearchRequest> Search(AgencySearchRequest searchRequest) { //make sure at least one field set //Check.Require(searchRequest != null, "At least one field is required"); //if (String.IsNullOrEmpty(searchRequest.AgencyQuery)) //{ // Check.Require(1 == 0, "At least one field is required"); //} if (searchRequest.CurrentPageNumber == 0) { searchRequest.CurrentPageNumber = 1; } if (string.IsNullOrEmpty(searchRequest.SortColumn)) { searchRequest.SortColumn = DEFAULT_SORT_COLUMN; searchRequest.SortOrder = DEFAULT_SORT_ORDER; } const int entriesPerPage = 20; int offset = entriesPerPage * (searchRequest.CurrentPageNumber - 1); IList <AgencyDto> searchResultItems = _agencyRepository.Search(searchRequest, offset, entriesPerPage); var searchResultFormViewModel = CreateFormViewModel(searchRequest); searchResultFormViewModel.PageResultItems = searchResultItems; int resultCount = _agencyRepository.GetSearchTotal(searchRequest); searchResultFormViewModel.TotalResultCount = resultCount; searchResultFormViewModel.CurrentPageNumber = searchRequest.CurrentPageNumber; searchResultFormViewModel.TotalPageCount = resultCount / entriesPerPage; if (resultCount % entriesPerPage > 0) { searchResultFormViewModel.TotalPageCount++; } return(searchResultFormViewModel); }