public SearchResultFormViewModel<WrmsSystemDto, WrmsSystemSearchRequest> Search( WrmsSystemSearchRequest searchRequest) { var entriesPerPage = 20; if (searchRequest.CurrentPageNumber == 0) { searchRequest.CurrentPageNumber = 1; } if (string.IsNullOrEmpty(searchRequest.SortColumn)) { searchRequest.SortColumn = DEFAULT_SORT_COLUMN; searchRequest.SortOrder = DEFAULT_SORT_ORDER; } int offset = entriesPerPage * (searchRequest.CurrentPageNumber - 1); IList<WrmsSystemDto> searchResultItems = _wrmsSystemRepository.Search(searchRequest, offset, entriesPerPage); var searchResultFormViewModel = CreateFormViewModel(searchRequest); searchResultFormViewModel.PageResultItems = searchResultItems; int resultCount = _wrmsSystemRepository.GetSearchTotal(searchRequest); searchResultFormViewModel.TotalResultCount = resultCount; searchResultFormViewModel.CurrentPageNumber = searchRequest.CurrentPageNumber; searchResultFormViewModel.TotalPageCount = resultCount / entriesPerPage; if (resultCount % entriesPerPage > 0) { searchResultFormViewModel.TotalPageCount++; } return searchResultFormViewModel; }
public SearchResultFormViewModel<WrmsSystemDto, WrmsSystemSearchRequest> CreateFormViewModel( WrmsSystemSearchRequest searchRequest) { var viewModel = new SearchResultFormViewModel<WrmsSystemDto, WrmsSystemSearchRequest>(); viewModel.SearchRequest = searchRequest; //searchRequest.Contacts = _personManagementService.GetActiveStaff(); searchRequest.Contacts = _personManagementService.GetAll(); return viewModel; }
public virtual void CanSearch() { var searchRequest = new WrmsSystemSearchRequest(); searchRequest.SystemQuery = "e"; IList<WrmsSystemDto> results = _wrmsSystemRepository.Search(searchRequest, 0, 20); Assert.That(results.Count > 1 && results.Count <= 20); }
public virtual void CanSearchWithTextSortedByShortDescriptionDesc() { var searchRequest = new WrmsSystemSearchRequest(); searchRequest.SystemQuery = "system"; searchRequest.SortColumn = "ShortDesc"; searchRequest.SortOrder = "Desc"; IList<WrmsSystemDto> result = _wrmsSystemRepository.Search(searchRequest, 0, 10); Assert.That(result.Count > 0); Assert.That(result[0].ShortDesc.CompareTo(result[1].ShortDesc) >= 0); Assert.That(result[0].ShortDesc.CompareTo(result[result.Count - 1].ShortDesc) >= 0); foreach (var val in result) { if (val.Id == 307) //307 is inactive { Assert.That(false); } } }
public virtual void CanGetSearchTotal() { var searchRequest = new WrmsSystemSearchRequest(); searchRequest.SystemQuery = "Big Fix"; int results = _wrmsSystemRepository.GetSearchTotal(searchRequest); Assert.That(results == 1); }