コード例 #1
0
        public SearchResultsPaginationViewModel GetSearchResultsByTag(string tagName, int pageNumber)
        {
            if (!IsAuthorize("read"))
            {
                return null;
            }
            var searchResultsPagination = new SearchResultsPaginationViewModel();
            var data = this.GetSearchResultsViewModel(_facade.GetResourceByTagName(tagName).ToList());
            if (data != null)
            {
                var totalData = data.Count();

                double resultToDisplay = 18;
                double pagecount = Math.Ceiling(totalData / resultToDisplay);
                int totalPage = totalData > resultToDisplay ? Convert.ToInt32(pagecount) : 1;
                int actualDisplay = totalData < resultToDisplay ? totalData : Convert.ToInt32(resultToDisplay);

                searchResultsPagination.SearchResult = data.Skip(actualDisplay * pageNumber).Take(actualDisplay);
                searchResultsPagination.TotalPage = totalPage;
            }
            return searchResultsPagination;
        }
コード例 #2
0
        public SearchResultsPaginationViewModel GetSearchResultsPagination(string searchText, int pageNumber)
        {
            if (!IsAuthorize("read"))
            {
                return null;
            }
            var searchResultsPagination = new SearchResultsPaginationViewModel();
            try
            {
                var data = this.GetSearchResultsViewModel(_facade.GetSearchResults(searchText));
                if (data != null)
                {
                    var totalData = data.Count();

                    double resultToDisplay = 18;
                    double pagecount = Math.Ceiling(totalData / resultToDisplay);
                    int totalPage = totalData > resultToDisplay ? Convert.ToInt32(pagecount) : 1;
                    int actualDisplay = totalData < resultToDisplay ? totalData : Convert.ToInt32(resultToDisplay);

                    searchResultsPagination.SearchResult = data.Skip(actualDisplay * pageNumber).Take(actualDisplay);
                    searchResultsPagination.TotalPage = totalPage;
                }
            }
            catch (Exception e)
            {

            }
            return searchResultsPagination;
        }