Exemplo n.º 1
0
        /// <summary>
        /// Provides fulltext search for MVC application.
        /// </summary>
        /// <param name="query">Text to search</param>
        /// <param name="pageIndex">Page index</param>
        /// <param name="pageSize">Page size</param>
        public virtual SearchResults Search(string query, int? pageIndex, int pageSize)
        {
            var page = (pageIndex ?? 1) - 1;

            var searchResults = new SearchResults
            {
                PageIndex = page,
                PageSize = pageSize,
                Query = query
            };

            if (String.IsNullOrWhiteSpace(query))
            {
                searchResults.TotalItemCount = 0;
                return searchResults;
            }

            int numberOfResults;
            SearchInternal(query, page, pageSize, out numberOfResults);

            searchResults.TotalItemCount = numberOfResults;
            searchResults.Items = GetSearchItems();

            return searchResults;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Provides fulltext search for MVC application.
        /// </summary>
        /// <param name="query">Text to search</param>
        /// <param name="pageIndex">Page index</param>
        /// <param name="pageSize">Page size</param>
        public virtual SearchResults Search(string query, int?pageIndex, int pageSize)
        {
            var page = (pageIndex ?? 1) - 1;

            var searchResults = new SearchResults
            {
                PageIndex = page,
                PageSize  = pageSize,
                Query     = query
            };

            if (String.IsNullOrWhiteSpace(query))
            {
                searchResults.TotalItemCount = 0;
                return(searchResults);
            }

            int numberOfResults;

            SearchInternal(query, page, pageSize, out numberOfResults);

            searchResults.TotalItemCount = numberOfResults;
            searchResults.Items          = GetSearchItems();

            return(searchResults);
        }