/// <summary> /// Creates a new instance of the <see cref="ContentItemQuerySettings"></see> class. /// </summary> /// <param name="sortBy">Indicates on which property to sort.</param> /// <param name="sortDirection">Indicates the sort direction.</param> /// <param name="pageSize">The page size.</param> /// <param name="pageNumber">The page number (starting from 1 as the first page).</param> public ContentItemQuerySettings(ContentItemSortBy sortBy, ContentItemSortDirection sortDirection, int? pageSize, int? pageNumber) { SortBy = sortBy; SortDirection = sortDirection; PageSize = pageSize; PageNumber = pageNumber; }
/// <summary> /// Creates a new instance of the <see cref="ContentItemQuerySettings"></see> class. /// </summary> /// <param name="sortBy">Indicates on which property to sort.</param> /// <param name="sortDirection">Indicates the sort direction.</param> /// <param name="pageSize">The page size.</param> /// <param name="pageNumber">The page number (starting from 1 as the first page).</param> public ContentItemQuerySettings(ContentItemSortBy sortBy, ContentItemSortDirection sortDirection, int?pageSize, int?pageNumber) { SortBy = sortBy; SortDirection = sortDirection; PageSize = pageSize; PageNumber = pageNumber; }
private ContentItemQuerySettings CreateQuerySettingsForModule(int?pageSize, int?pageNumber) { // Map sortby and sortdirection to the ones of the content item. We don't use these in the articles module // because we need to convert all module settings for. Maybe sometime in the future. ContentItemSortBy sortBy = ContentItemSortBy.None; switch (this._sortBy) { case SortBy.CreatedBy: sortBy = ContentItemSortBy.CreatedBy; break; case SortBy.DateCreated: sortBy = ContentItemSortBy.CreatedAt; break; case SortBy.DateModified: sortBy = ContentItemSortBy.ModifiedAt; break; case SortBy.DateOnline: sortBy = ContentItemSortBy.PublishedAt; break; case SortBy.ModifiedBy: sortBy = ContentItemSortBy.ModifiedBy; break; case SortBy.Title: sortBy = ContentItemSortBy.Title; break; } ContentItemSortDirection sortDirection = this._sortDirection == SortDirection.ASC ? ContentItemSortDirection.ASC : ContentItemSortDirection.DESC; return(new ContentItemQuerySettings(sortBy, sortDirection, pageSize, pageNumber)); }
/// <summary> /// Adds sorting to the DetachedCriteria based on the given parameters. /// </summary> /// <param name="criteria"></param> /// <param name="contentItemSortBy"></param> /// <param name="contentItemSortDirection"></param> /// <returns></returns> public static DetachedCriteria ApplyOrdering(this DetachedCriteria criteria, ContentItemSortBy contentItemSortBy, ContentItemSortDirection contentItemSortDirection) { DetachedCriteria orderedCriteria = criteria; if (contentItemSortDirection != ContentItemSortDirection.None) { switch (contentItemSortDirection) { case ContentItemSortDirection.ASC: orderedCriteria = criteria.AddOrder(Order.Asc(contentItemSortBy.ToString())); break; case ContentItemSortDirection.DESC: orderedCriteria = criteria.AddOrder(Order.Desc(contentItemSortBy.ToString())); break; } } return orderedCriteria; }
/// <summary> /// Creates a new instance of the <see cref="ContentItemQuerySettings"></see> class. /// </summary> /// <param name="sortBy">Indicates on which property to sort.</param> /// <param name="sortDirection">Indicates the sort direction.</param> public ContentItemQuerySettings(ContentItemSortBy sortBy, ContentItemSortDirection sortDirection) : this(sortBy, sortDirection, null, null) { }
/// <summary> /// Adds sorting to the DetachedCriteria based on the given parameters. /// </summary> /// <param name="criteria"></param> /// <param name="contentItemSortBy"></param> /// <param name="contentItemSortDirection"></param> /// <returns></returns> public static DetachedCriteria ApplyOrdering(this DetachedCriteria criteria, ContentItemSortBy contentItemSortBy, ContentItemSortDirection contentItemSortDirection) { DetachedCriteria orderedCriteria = criteria; if (contentItemSortDirection != ContentItemSortDirection.None) { switch (contentItemSortDirection) { case ContentItemSortDirection.ASC: orderedCriteria = criteria.AddOrder(Order.Asc(contentItemSortBy.ToString())); break; case ContentItemSortDirection.DESC: orderedCriteria = criteria.AddOrder(Order.Desc(contentItemSortBy.ToString())); break; } } return(orderedCriteria); }