/// <summary> /// Gets a list of all changes for a specified path. /// </summary> /// <param name="model">The model.</param> /// <param name="db">The database.</param> /// <param name="path">The path.</param> /// <returns></returns> public static ContentListViewModel Populate(this ContentListViewModel model, ProviderPortalEntities db, string path) { model = new ContentListViewModel { Items = new List <ContentListViewModelItem>(), DisplayMode = ContentListDisplayMode.History }; bool canManageContent = Permission.HasPermission(false, true, Permission.PermissionName.CanManageContent); if (!canManageContent) { return(model); } path = ContentManager.TrimPath(path); model.Items = db.Contents .Where(x => x.Path.Equals(path) && x.RecordStatusId != (int)Constants.RecordStatus.Deleted) .Select(x => new ContentListViewModelItem { ContentId = x.ContentId, Path = x.Path, Title = x.Title, UserContext = (UserContext.UserContextName)x.UserContext, RecordStatus = (Constants.RecordStatus)x.RecordStatusId, Embed = x.Embed, LastModifiedDateTimeUtc = x.ModifiedDateTimeUtc ?? x.CreatedDateTimeUtc, LastModifiedBy = x.AspNetUser1.Name ?? x.AspNetUser.Name, Language = x.Language.DefaultText, Version = x.Version, Summary = x.Summary }).OrderByDescending(x => x.Version).ToList(); return(model); }
/// <summary> /// Gets a list of all archived items. /// </summary> /// <param name="model">The model.</param> /// <param name="db">The database.</param> /// <returns></returns> public static ContentListViewModel PopulateArchived(this ContentListViewModel model, ProviderPortalEntities db) { model = new ContentListViewModel { Items = new List <ContentListViewModelItem>(), DisplayMode = ContentListDisplayMode.Index }; bool canManageContent = Permission.HasPermission(false, true, Permission.PermissionName.CanManageContent); if (!canManageContent) { return(model); } var notArchived = db.Contents .Where( x => x.RecordStatusId == (int)Constants.RecordStatus.Live || x.RecordStatusId == (int)Constants.RecordStatus.Pending) .Select(x => x.Path.ToLower()).ToList(); model.Items = db.Contents .Where( x => !notArchived.Contains(x.Path.ToLower())) .Select(x => new ContentListViewModelItem { ContentId = x.ContentId, Path = x.Path, Title = x.Title, UserContext = (UserContext.UserContextName)x.UserContext, RecordStatus = (Constants.RecordStatus)x.RecordStatusId, Embed = x.Embed, LastModifiedDateTimeUtc = x.ModifiedDateTimeUtc ?? x.CreatedDateTimeUtc, LastModifiedBy = x.AspNetUser1.Name ?? x.AspNetUser.Name, Language = x.Language.DefaultText, Version = x.Version, Summary = x.Summary }).OrderBy(x => x.Path).ThenByDescending(x => x.Version).ToList(); return(model); }