当前位置: 首页>>代码示例>>C#>>正文


C# PageService.Delete方法代码示例

本文整理汇总了C#中Rock.Model.PageService.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# PageService.Delete方法的具体用法?C# PageService.Delete怎么用?C# PageService.Delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rock.Model.PageService的用法示例。


在下文中一共展示了PageService.Delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: gPages_Delete

        /// <summary>
        /// Handles the Delete event of the gPages 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 gPages_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            PageService pageService = new PageService( rockContext );
            var pageViewService = new PageViewService(rockContext);
            var siteService = new SiteService(rockContext);

            Rock.Model.Page page = pageService.Get( new Guid( e.RowKeyValue.ToString() ) );
            if ( page != null )
            {
                string errorMessage;
                if ( !pageService.CanDelete( page, out errorMessage, includeSecondLvl: true ) )
                {
                    mdGridWarning.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();

                PageCache.Flush( page.Id );
            }

            BindPagesGrid();
        }
开发者ID:RMRDevelopment,项目名称:Rockit,代码行数:56,代码来源:PageList.ascx.cs

示例2: rGrid_Delete

        /// <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();
        }
开发者ID:Higherbound,项目名称:Higherbound-2016-website-upgrades,代码行数:63,代码来源:Pages.ascx.cs

示例3: rGrid_Delete

        protected void rGrid_Delete( object sender, RowEventArgs e )
        {
            using ( new UnitOfWorkScope() )
            {
                var pageService = new PageService();
                var siteService = new SiteService();

                var page = pageService.Get( (int)rGrid.DataKeys[e.RowIndex]["id"] );
                if ( page != null )
                {
                    RockTransactionScope.WrapTransaction( () =>
                    {
                        foreach ( var site in siteService.Queryable() )
                        {
                            bool updateSite = false;
                            if (site.DefaultPageId == page.Id)
                            {
                                site.DefaultPageId = null;
                                site.DefaultPageRouteId = null;
                                updateSite = true;
                            }
                            if (site.LoginPageId == page.Id)
                            {
                                site.LoginPageId = null;
                                site.LoginPageRouteId = null;
                                updateSite = true;
                            }
                            if (site.RegistrationPageId == page.Id)
                            {
                                site.RegistrationPageId = null;
                                site.RegistrationPageRouteId = null;
                                updateSite = true;
                            }

                            if (updateSite)
                            {
                                siteService.Save( site, CurrentPersonId );
                            }
                        }

                        pageService.Delete( page, CurrentPersonId );
                        pageService.Save( page, CurrentPersonId );

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

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

            BindGrid();
        }
开发者ID:pkdevbox,项目名称:Rock,代码行数:53,代码来源:Pages.ascx.cs

示例4: gPages_Delete

        /// <summary>
        /// Handles the Delete event of the gPages 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 gPages_Delete( object sender, RowEventArgs e )
        {
            bool canDelete = false;

            var rockContext = new RockContext();
            PageService pageService = new PageService( rockContext );

            Rock.Model.Page page = pageService.Get( new Guid( e.RowKeyValue.ToString() ) );
            if ( page != null )
            {
                string errorMessage;
                canDelete = pageService.CanDelete( page, out errorMessage, includeSecondLvl: true );
                if ( !canDelete )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Alert );
                    return;
                }

                pageService.Delete( page );

                rockContext.SaveChanges();

                PageCache.Flush( page.Id );
            }

            BindPagesGrid();
        }
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:32,代码来源:PageList.ascx.cs

示例5: rGrid_Delete

        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( (int)rGrid.DataKeys[e.RowIndex]["id"] );
            if ( page != null )
            {
                string errorMessage = string.Empty;
                if ( !pageService.CanDelete( page, out errorMessage ) )
                {
                    //errorMessage = "The page is the parent page of another page.";
                    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;
                    }
                }

                // TODO: Could be thousands of page views.  Can we set this up as cascade?
                foreach( var pageView in pageViewService.GetByPageId(page.Id))
                {
                    pageViewService.Delete( pageView );
                }
                pageService.Delete( page );

                rockContext.SaveChanges();

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

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

            BindGrid();
        }
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:56,代码来源:Pages.ascx.cs


注:本文中的Rock.Model.PageService.Delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。