Rock.Model.PageViewService.GetByPageId C# (CSharp) Method

GetByPageId() public method

Returns an enumerable collection of Rock.Model.PageView entities by the Id of the Rock.Model.Page
public GetByPageId ( int pageId ) : IEnumerable
pageId int The page identifier.
return IEnumerable
        public IEnumerable<PageView> GetByPageId( int? pageId )
        {
            return Queryable().Where( t => ( t.PageId != null && t.PageId == pageId ) || ( pageId == null && t.PageId == null ) );
        }

Usage Example

コード例 #1
0
        /// <summary>
        /// Handles the Delete event of the rGrid control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
        protected void rGrid_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            var pageService = new PageService( rockContext );
            var pageViewService = new PageViewService( rockContext );
            var siteService = new SiteService( rockContext );

            var page = pageService.Get( e.RowKeyId );
            if ( page != null )
            {
                string errorMessage = string.Empty;
                if ( !pageService.CanDelete( page, out errorMessage ) )
                {
                    mdDeleteWarning.Show( errorMessage, ModalAlertType.Alert );
                    return;
                }

                foreach ( var site in siteService.Queryable() )
                {
                    if ( site.DefaultPageId == page.Id )
                    {
                        site.DefaultPageId = null;
                        site.DefaultPageRouteId = null;
                    }

                    if ( site.LoginPageId == page.Id )
                    {
                        site.LoginPageId = null;
                        site.LoginPageRouteId = null;
                    }

                    if ( site.RegistrationPageId == page.Id )
                    {
                        site.RegistrationPageId = null;
                        site.RegistrationPageRouteId = null;
                    }
                }

                foreach ( var pageView in pageViewService.GetByPageId( page.Id ) )
                {
                    pageView.Page = null;
                    pageView.PageId = null;
                }

                pageService.Delete( page );

                rockContext.SaveChanges();

                Rock.Web.Cache.PageCache.Flush( page.Id );

                if ( _page != null )
                {
                    _page.FlushChildPages();
                }
            }

            BindGrid();
        }
All Usage Examples Of Rock.Model.PageViewService::GetByPageId