本文整理汇总了C#中Rock.Model.AttributeService.CanDelete方法的典型用法代码示例。如果您正苦于以下问题:C# AttributeService.CanDelete方法的具体用法?C# AttributeService.CanDelete怎么用?C# AttributeService.CanDelete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.AttributeService
的用法示例。
在下文中一共展示了AttributeService.CanDelete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: gDefinedTypeAttributes_Delete
/// <summary>
/// Handles the Delete event of the gDefinedTypeAttributes 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 gDefinedTypeAttributes_Delete( object sender, RowEventArgs e )
{
Guid attributeGuid = (Guid)e.RowKeyValue;
var rockContext = new RockContext();
AttributeService attributeService = new AttributeService( rockContext );
Attribute attribute = attributeService.Get( attributeGuid );
if ( attribute != null )
{
string errorMessage;
if ( !attributeService.CanDelete( attribute, out errorMessage ) )
{
mdGridWarningAttributes.Show( errorMessage, ModalAlertType.Information );
return;
}
AttributeCache.Flush( attribute.Id );
attributeService.Delete( attribute );
rockContext.SaveChanges();
}
BindDefinedTypeAttributesGrid();
}
示例2: gWorkflowTypeAttributes_Delete
/// <summary>
/// Handles the Delete event of the gWorkflowTypeAttributes 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 gWorkflowTypeAttributes_Delete( object sender, RowEventArgs e )
{
Guid attributeGuid = (Guid)e.RowKeyValue;
AttributeService attributeService = new AttributeService();
Attribute attribute = attributeService.Get( attributeGuid );
if ( attribute != null )
{
string errorMessage;
if ( !attributeService.CanDelete( attribute, out errorMessage ) )
{
mdGridWarningAttributes.Show( errorMessage, ModalAlertType.Information );
return;
}
Rock.Web.Cache.AttributeCache.Flush( attribute.Id );
attributeService.Delete( attribute, CurrentPersonId );
attributeService.Save( attribute, CurrentPersonId );
}
// reload page so that other blocks respond to any data that was changed
var qryParams = new Dictionary<string, string>();
qryParams["workflowTypeId"] = hfWorkflowTypeId.Value;
NavigateToPage( RockPage.Guid, qryParams );
}