本文整理汇总了C#中Rock.Model.GroupTypeService.CanDelete方法的典型用法代码示例。如果您正苦于以下问题:C# GroupTypeService.CanDelete方法的具体用法?C# GroupTypeService.CanDelete怎么用?C# GroupTypeService.CanDelete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupTypeService
的用法示例。
在下文中一共展示了GroupTypeService.CanDelete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: gGroupType_Delete
/// <summary>
/// Handles the Delete event of the gGroupType 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 gGroupType_Delete( object sender, RowEventArgs e )
{
var rockContext = new RockContext();
GroupTypeService groupTypeService = new GroupTypeService( rockContext );
GroupType groupType = groupTypeService.Get( e.RowKeyId );
if ( groupType != null )
{
int groupTypeId = groupType.Id;
if ( !groupType.IsAuthorized( "Administrate", CurrentPerson ) )
{
mdGridWarning.Show( "Sorry, you're not authorized to delete this group type.", ModalAlertType.Alert );
return;
}
string errorMessage;
if ( !groupTypeService.CanDelete( groupType, out errorMessage ) )
{
mdGridWarning.Show( errorMessage, ModalAlertType.Alert );
return;
}
groupType.ParentGroupTypes.Clear();
groupType.ChildGroupTypes.Clear();
groupTypeService.Delete( groupType );
rockContext.SaveChanges();
GroupTypeCache.Flush( groupTypeId );
}
BindGrid();
}
示例2: btnDelete_Click
/// <summary>
/// Handles the Click event of the btnDelete 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 btnDelete_Click( object sender, EventArgs e )
{
var rockContext = new RockContext();
GroupTypeService groupTypeService = new GroupTypeService( rockContext );
GroupType groupType = groupTypeService.Get( hfGroupTypeId.Value.AsInteger() );
if ( groupType != null )
{
string errorMessage;
if ( !groupTypeService.CanDelete( groupType, out errorMessage ) )
{
mdDeleteWarning.Show( errorMessage, ModalAlertType.Information );
return;
}
int groupTypeId = groupType.Id;
groupType.ParentGroupTypes.Clear();
groupType.ChildGroupTypes.Clear();
groupTypeService.Delete( groupType );
rockContext.SaveChanges();
GroupTypeCache.Flush( groupTypeId );
Rock.CheckIn.KioskDevice.FlushAll();
}
var pageRef = new PageReference( CurrentPageReference.PageId, CurrentPageReference.RouteId );
NavigateToPage( pageRef );
}
示例3: CheckinAreaRow_DeleteAreaClick
private void CheckinAreaRow_DeleteAreaClick( object sender, EventArgs e )
{
var row = sender as CheckinAreaRow;
using ( var rockContext = new RockContext() )
{
var groupTypeService = new GroupTypeService( rockContext );
var groupType = groupTypeService.Get( row.GroupTypeGuid );
if ( groupType != null )
{
// Warn if this GroupType or any of its child grouptypes (recursive) is being used as an Inherited Group Type. Probably shouldn't happen, but just in case
if ( IsInheritedGroupTypeRecursive( groupType, groupTypeService ) )
{
nbDeleteWarning.Text = "WARNING - Cannot delete. This group type or one of its child group types is assigned as an inherited group type.";
nbDeleteWarning.Visible = true;
return;
}
string errorMessage;
if ( !groupTypeService.CanDelete( groupType, out errorMessage ) )
{
nbDeleteWarning.Text = "WARNING - Cannot Delete: " + errorMessage;
nbDeleteWarning.Visible = true;
return;
}
int id = groupType.Id;
groupType.ParentGroupTypes.Clear();
groupType.ChildGroupTypes.Clear();
groupTypeService.Delete( groupType );
rockContext.SaveChanges();
GroupTypeCache.Flush( id );
Rock.CheckIn.KioskDevice.FlushAll();
SelectArea( null );
}
}
BuildRows();
}
示例4: gGroupType_Delete
/// <summary>
/// Handles the Delete event of the gGroupType 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 gGroupType_Delete( object sender, RowEventArgs e )
{
RockTransactionScope.WrapTransaction( () =>
{
GroupTypeService groupTypeService = new GroupTypeService();
GroupType groupType = groupTypeService.Get( e.RowKeyId );
if ( groupType != null )
{
int groupTypeId = groupType.Id;
if ( !groupType.IsAuthorized("Administrate", CurrentPerson))
{
mdGridWarning.Show( "Sorry, you're not authorized to delete this group type.", ModalAlertType.Alert );
return;
}
string errorMessage;
if ( !groupTypeService.CanDelete( groupType, out errorMessage ) )
{
mdGridWarning.Show( errorMessage, ModalAlertType.Alert );
return;
}
groupTypeService.Delete( groupType, CurrentPersonId );
groupTypeService.Save( groupType, CurrentPersonId );
GroupTypeCache.Flush( groupTypeId );
}
} );
BindGrid();
}