本文整理汇总了C#中Rock.Model.PageService.CanDelete方法的典型用法代码示例。如果您正苦于以下问题:C# PageService.CanDelete方法的具体用法?C# PageService.CanDelete怎么用?C# PageService.CanDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.PageService
的用法示例。
在下文中一共展示了PageService.CanDelete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: 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();
}
示例3: 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();
}
示例4: 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();
}