コード例 #1
0
ファイル: ForumSearchQuery.cs プロジェクト: Nagabhushana/nag
        public ForumSearchQuery SortBy(ForumTopicSorting sort)
        {
            switch (sort)
            {
            case ForumTopicSorting.SubjectAsc:
            case ForumTopicSorting.SubjectDesc:
                return(SortBy(SearchSort.ByStringField("subject", sort == ForumTopicSorting.SubjectDesc)));

            case ForumTopicSorting.UserNameAsc:
            case ForumTopicSorting.UserNameDesc:
                return(SortBy(SearchSort.ByStringField("username", sort == ForumTopicSorting.UserNameDesc)));

            case ForumTopicSorting.CreatedOnAsc:
            case ForumTopicSorting.CreatedOnDesc:
                return(SortBy(SearchSort.ByDateTimeField("createdon", sort == ForumTopicSorting.CreatedOnDesc)));

            case ForumTopicSorting.PostsAsc:
            case ForumTopicSorting.PostsDesc:
                return(SortBy(SearchSort.ByIntField("numposts", sort == ForumTopicSorting.PostsDesc)));

            case ForumTopicSorting.Relevance:
                return(SortBy(SearchSort.ByRelevance()));

            default:
                return(this);
            }
        }
コード例 #2
0
        public CatalogSearchQuery SortBy(ProductSortingEnum sort)
        {
            switch (sort)
            {
            case ProductSortingEnum.CreatedOnAsc:
            case ProductSortingEnum.CreatedOn:
                return(SortBy(SearchSort.ByDateTimeField("createdon", sort == ProductSortingEnum.CreatedOn)));

            case ProductSortingEnum.NameAsc:
            case ProductSortingEnum.NameDesc:
                return(SortBy(SearchSort.ByStringField("name", sort == ProductSortingEnum.NameDesc)));

            case ProductSortingEnum.PriceAsc:
            case ProductSortingEnum.PriceDesc:
                return(SortBy(SearchSort.ByDoubleField("price", sort == ProductSortingEnum.PriceDesc)));

            case ProductSortingEnum.Relevance:
                return(SortBy(SearchSort.ByRelevance()));

            default:
                return(this);
            }
        }