Ejemplo n.º 1
0
        private CatalogEntrySearchCriteria CreateCriteria(IContent currentContent, FilterOptionFormModel filterOptions)
        {
            var pageSize  = filterOptions.PageSize > 0 ? filterOptions.PageSize : _defaultPageSize;
            var sortOrder = GetSortOrder().FirstOrDefault(x => x.Name.ToString() == filterOptions.Sort) ?? GetSortOrder().First();
            var market    = _currentMarket.GetCurrentMarket();

            var criteria = new CatalogEntrySearchCriteria
            {
                ClassTypes = new StringCollection {
                    "product"
                },
                Locale            = _preferredCulture.Name,
                MarketId          = market.MarketId,
                StartingRecord    = pageSize * (filterOptions.Page - 1),
                RecordsToRetrieve = pageSize,
                Sort = new SearchSort(new SearchSortField(sortOrder.Key, sortOrder.SortDirection == SortDirection.Descending))
            };

            var nodeContent = currentContent as NodeContent;

            if (nodeContent != null)
            {
                criteria.Outlines = _search.GetOutlinesForNode(nodeContent.Code);
            }
            if (!string.IsNullOrEmpty(filterOptions.Q))
            {
                criteria.SearchPhrase = GetEscapedSearchPhrase(filterOptions.Q);
            }

            return(criteria);
        }
Ejemplo n.º 2
0
        private CatalogEntrySearchCriteria CreateFullSearchCriteria(IContent currentContent, FilterOptionViewModel filterOptions)
        {
            var pageSize = filterOptions.PageSize > 0 ? filterOptions.PageSize : _defaultPageSize;
            var criteria = CreateDefaultCriteria(filterOptions);

            criteria.StartingRecord = pageSize * (filterOptions.Page - 1);

            var nodeContent = currentContent as NodeContent;

            if (nodeContent != null)
            {
                criteria.Outlines = _search.GetOutlinesForNode(nodeContent.Code);
            }

            return(criteria);
        }