/// <summary> /// Executes the query. /// </summary> /// <returns> /// The <see cref="PagedCollection"/>. /// </returns> public PagedCollection <IProductContent> Execute() { var hasCollections = CollectionKeys != null && CollectionKeys.Any(); if (!hasCollections) { return(HasSearchTerm ? _query.TypedProductContentSearchPaged(SearchTerm, Page, ItemsPerPage, SortBy, SortDirection) : _query.TypedProductContentSearchPaged(Page, ItemsPerPage, SortBy, SortDirection)); } switch (this.CollectionClusivity) { case CollectionClusivity.DoesNotExistInAnyCollectionsAndFilters: return(HasSearchTerm ? _query.TypedProductContentPageThatNotInAnyCollections(CollectionKeys, SearchTerm, Page, ItemsPerPage, SortBy, SortDirection) : _query.TypedProductContentPageThatNotInAnyCollections(CollectionKeys, Page, ItemsPerPage, SortBy, SortDirection)); case CollectionClusivity.ExistsInAnyCollectionOrFilter: return(HasSearchTerm ? _query.TypedProductContentPageThatExistsInAnyCollections(CollectionKeys, SearchTerm, Page, ItemsPerPage, SortBy, SortDirection) : _query.TypedProductContentPageThatExistsInAnyCollections(CollectionKeys, Page, ItemsPerPage, SortBy, SortDirection)); case CollectionClusivity.ExistsInAllCollectionsAndFilters: default: return(HasSearchTerm ? _query.TypedProductContentPageThatExistInAllCollections(CollectionKeys, SearchTerm, Page, ItemsPerPage, SortBy, SortDirection) : _query.TypedProductContentPageThatExistInAllCollections(CollectionKeys, Page, ItemsPerPage, SortBy, SortDirection)); } }
/// <summary> /// Executes the query. /// </summary> /// <returns> /// The <see cref="PagedCollection"/>. /// </returns> public PagedCollection <IProductContent> Execute() { var hasCollections = CollectionKeys != null && CollectionKeys.Any(); if (!hasCollections && !HasPriceRange) { return(HasSearchTerm ? _query.TypedProductContentSearchPaged(SearchTerm, Page, ItemsPerPage, SortBy, SortDirection) : _query.TypedProductContentSearchPaged(Page, ItemsPerPage, SortBy, SortDirection)); } if (!hasCollections && HasPriceRange) { if (!HasSearchTerm) { return(_query.TypedProductContentByPriceRange(MinPrice, MaxPrice, Page, ItemsPerPage, SortBy, SortDirection)); } // don't have a price range with a search term filter. var notImplemented = new NotImplementedException(); MultiLogHelper.Error <ProductContentQuery>("Typed product content by search term and price range has not been implemented", notImplemented); throw notImplemented; } switch (this.CollectionClusivity) { case CollectionClusivity.DoesNotExistInAnyCollectionsAndFilters: if (!HasPriceRange) { return(HasSearchTerm ? _query.TypedProductContentPageThatNotInAnyCollections(CollectionKeys, SearchTerm, Page, ItemsPerPage, SortBy, SortDirection) : _query.TypedProductContentPageThatNotInAnyCollections(CollectionKeys, Page, ItemsPerPage, SortBy, SortDirection)); } return(HasSearchTerm ? _query.TypedProductContentPageThatNotInAnyCollections(CollectionKeys, SearchTerm, MinPrice, MaxPrice, Page, ItemsPerPage, SortBy, SortDirection) : _query.TypedProductContentPageThatNotInAnyCollections(CollectionKeys, MinPrice, MaxPrice, Page, ItemsPerPage, SortBy, SortDirection)); case CollectionClusivity.ExistsInAnyCollectionOrFilter: if (!HasPriceRange) { return(HasSearchTerm ? _query.TypedProductContentPageThatExistsInAnyCollections(CollectionKeys, SearchTerm, Page, ItemsPerPage, SortBy, SortDirection) : _query.TypedProductContentPageThatExistsInAnyCollections(CollectionKeys, Page, ItemsPerPage, SortBy, SortDirection)); } return(HasSearchTerm ? _query.TypedProductContentPageThatExistsInAnyCollections(CollectionKeys, SearchTerm, MinPrice, MaxPrice, Page, ItemsPerPage, SortBy, SortDirection) : _query.TypedProductContentPageThatExistsInAnyCollections(CollectionKeys, MinPrice, MaxPrice, Page, ItemsPerPage, SortBy, SortDirection)); case CollectionClusivity.ExistsInAllCollectionsAndFilters: default: if (!HasPriceRange) { return(HasSearchTerm ? _query.TypedProductContentPageThatExistInAllCollections(CollectionKeys, SearchTerm, Page, ItemsPerPage, SortBy, SortDirection) : _query.TypedProductContentPageThatExistInAllCollections(CollectionKeys, Page, ItemsPerPage, SortBy, SortDirection)); } return(HasSearchTerm ? _query.TypedProductContentPageThatExistInAllCollections(CollectionKeys, SearchTerm, MinPrice, MaxPrice, Page, ItemsPerPage, SortBy, SortDirection) : _query.TypedProductContentPageThatExistInAllCollections(CollectionKeys, MinPrice, MaxPrice, Page, ItemsPerPage, SortBy, SortDirection)); } }