Rock.Model.BlockService.GetByPageAndZone C# (CSharp) Method

GetByPageAndZone() public method

Returns a collection of Blocks that are implemented in a Zone on a specific page.
public GetByPageAndZone ( int pageId, string zone ) : IQueryable
pageId int An that represents the Id of that a may be implemented on.
zone string A that represents the name of a page/layout zone that a may be implemented on.
return IQueryable
        public IQueryable<Block> GetByPageAndZone( int pageId, string zone )
        {
            return Queryable()
                .Where( t =>
                    t.PageId == pageId &&
                    string.Compare( t.Zone, zone ) == 0 )
                .OrderBy( t => t.Order );
        }

Usage Example

Ejemplo n.º 1
0
        /// <summary>
        /// Handles the GridReorder event of the gPageBlocks control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gPageBlocks_GridReorder( object sender, GridReorderEventArgs e )
        {
            using ( var rockContext = new RockContext() )
            {
                BlockService blockService = new BlockService( rockContext );
                var blocks = blockService.GetByPageAndZone( _Page.Id, _ZoneName ).ToList();
                blockService.Reorder( blocks, e.OldIndex, e.NewIndex );
                rockContext.SaveChanges();
            }

            _Page.FlushBlocks();
            PageUpdated = true;

            BindGrids();
        }
All Usage Examples Of Rock.Model.BlockService::GetByPageAndZone