Пример #1
0
        public virtual void CanGetSearchTotal()
        {
            var searchRequest = new WrmsSystemSearchRequest();

            searchRequest.SystemQuery = "Big Fix";

            int results = _wrmsSystemRepository.GetSearchTotal(searchRequest);

            Assert.That(results == 1);
        }
Пример #2
0
        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);
        }