Rock.Model.HtmlContentService.GetContent C# (CSharp) Метод

GetContent() публичный Метод

Returns an enumerable collection containing all versions of Rock.Model.HtmlContent for a specific Rock.Model.Block and/or EntityContext.
public GetContent ( int blockId, string entityValue ) : IOrderedQueryable
blockId int A representing the Id of a .
entityValue string A representing the EntityValue. This value is nullable.
Результат IOrderedQueryable
        public IOrderedQueryable<HtmlContent> GetContent( int blockId, string entityValue )
        {
            var content = Queryable( "ModifiedByPersonAlias.Person" );

            // If an entity value is specified, then return content specific to that context,
            // otherwise return content for the current block instance
            if ( !string.IsNullOrEmpty( entityValue ) )
            {
                content = content.Where( c => c.EntityValue == entityValue );
            }
            else
            {
                content = content.Where( c => c.BlockId == blockId );
            }

            // return the most recently approved item
            return content.OrderByDescending( c => c.Version );
        }

Usage Example

Пример #1
0
        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            var htmlContentService = new HtmlContentService();
            var content = htmlContentService.GetContent( this.BlockId, EntityValue() );

            var versions = content.Select( v =>
                new
                {
                    v.Id,
                    v.Version,
                    VersionText = "Version " + v.Version.ToString(),
                    ModifiedDateTime = "(" + v.LastModifiedDateTime.ToElapsedString() + ")",
                    ModifiedByPerson = v.LastModifiedPerson,
                    Approved = v.IsApproved,
                    ApprovedByPerson = v.ApprovedByPerson,
                    v.StartDateTime,
                    v.ExpireDateTime
                } ).ToList();

            gVersions.DataSource = versions;
            gVersions.GridRebind += gVersions_GridRebind;
            gVersions.DataBind();
        }
All Usage Examples Of Rock.Model.HtmlContentService::GetContent