public Delete ( FinancialPersonSavedAccount item ) : bool | ||
item | FinancialPersonSavedAccount | The item. |
return | bool |
public override bool Delete( FinancialPersonSavedAccount item )
{
if ( item.FinancialPaymentDetailId.HasValue )
{
var paymentDetailsService = new FinancialPaymentDetailService( (Rock.Data.RockContext)this.Context );
var paymentDetail = paymentDetailsService.Get( item.FinancialPaymentDetailId.Value );
if ( paymentDetail != null )
{
paymentDetailsService.Delete( paymentDetail );
}
}
return base.Delete( item );
}
/// <summary> /// Handles the Delete event of the gSavedAccounts 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 gSavedAccounts_Delete( object sender, RowEventArgs e ) { var rockContext = new RockContext(); var service = new FinancialPersonSavedAccountService( rockContext ); var savedAccount = service.Get( e.RowKeyId ); string errorMessage; if ( savedAccount == null ) { return; } if ( !service.CanDelete( savedAccount, out errorMessage ) ) { mdGridWarning.Show( errorMessage, ModalAlertType.Information ); return; } service.Delete( savedAccount ); rockContext.SaveChanges(); BindGrid(); }