本文整理汇总了C#中Rock.Model.PageService.DeleteRange方法的典型用法代码示例。如果您正苦于以下问题:C# PageService.DeleteRange方法的具体用法?C# PageService.DeleteRange怎么用?C# PageService.DeleteRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.PageService
的用法示例。
在下文中一共展示了PageService.DeleteRange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnDeleteConfirm_Click
/// <summary>
/// Handles the Click event of the btnDeleteConfirm control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected void btnDeleteConfirm_Click( object sender, EventArgs e )
{
bool canDelete = false;
var rockContext = new RockContext();
SiteService siteService = new SiteService( rockContext );
Site site = siteService.Get( int.Parse( hfSiteId.Value ) );
LayoutService layoutService = new LayoutService( rockContext );
PageService pageService = new PageService( rockContext );
PageViewService pageViewService = new PageViewService( rockContext );
if ( site != null )
{
var sitePages = new List<int> {
site.DefaultPageId ?? -1,
site.LoginPageId ?? -1,
site.RegistrationPageId ?? -1,
site.PageNotFoundPageId ?? -1
};
foreach ( var pageView in pageViewService
.Queryable()
.Where( t =>
t.Page != null &&
t.Page.Layout != null &&
t.Page.Layout.SiteId == site.Id ) )
{
pageView.Page = null;
pageView.PageId = null;
}
var pageQry = pageService.Queryable( "Layout" )
.Where( t =>
t.Layout.SiteId == site.Id ||
sitePages.Contains( t.Id ) );
pageService.DeleteRange( pageQry );
var layoutQry = layoutService.Queryable()
.Where( l =>
l.SiteId == site.Id );
layoutService.DeleteRange( layoutQry );
rockContext.SaveChanges( true );
string errorMessage;
canDelete = siteService.CanDelete( site, out errorMessage, includeSecondLvl: true );
if ( !canDelete )
{
mdDeleteWarning.Show( errorMessage, ModalAlertType.Alert );
return;
}
siteService.Delete( site );
rockContext.SaveChanges();
SiteCache.Flush( site.Id );
}
NavigateToParentPage();
}