Cancel() public méthode

Cancels the specified scheduled transaction.
public Cancel ( FinancialScheduledTransaction scheduledTransaction, string &errorMessages ) : bool
scheduledTransaction FinancialScheduledTransaction The scheduled transaction.
errorMessages string The error messages.
Résultat bool
        protected void bbtnDelete_Click( object sender, EventArgs e )
        {
            BootstrapButton bbtnDelete = (BootstrapButton)sender;
            RepeaterItem riItem = (RepeaterItem)bbtnDelete.NamingContainer;

            HiddenField hfScheduledTransactionId = (HiddenField)riItem.FindControl( "hfScheduledTransactionId" );
            Literal content = (Literal)riItem.FindControl( "lLiquidContent" );
            Button btnEdit = (Button)riItem.FindControl( "btnEdit" );

            var rockContext = new Rock.Data.RockContext();
            FinancialScheduledTransactionService fstService = new FinancialScheduledTransactionService( rockContext );
            var currentTransaction = fstService.Get( Int32.Parse(hfScheduledTransactionId.Value) );

            string errorMessage = string.Empty;
            if ( fstService.Cancel( currentTransaction, out errorMessage ) )
            {
                rockContext.SaveChanges();
                content.Text = String.Format( "<div class='alert alert-success'>Your recurring {0} has been deleted.</div>", GetAttributeValue( "TransactionLabel" ).ToLower() );
            }
            else
            {
                content.Text = String.Format( "<div class='alert alert-danger'>An error occured while deleting your scheduled transation. Message: {0}</div>", errorMessage );
            }

            bbtnDelete.Visible = false;
            btnEdit.Visible = false;
        }
 private void DeleteOldTransaction( int scheduledTransactionId )
 {
     using ( var rockContext = new Rock.Data.RockContext() )
     {
         FinancialScheduledTransactionService fstService = new FinancialScheduledTransactionService( rockContext );
         var currentTransaction = fstService.Get( scheduledTransactionId );
         if ( currentTransaction != null && currentTransaction.FinancialGateway != null )
         {
             currentTransaction.FinancialGateway.LoadAttributes( rockContext );
         }
         string errorMessage = string.Empty;
         if ( fstService.Cancel( currentTransaction, out errorMessage ) )
         {
             try
             {
                 fstService.GetStatus( currentTransaction, out errorMessage );
             }
             catch { }
             rockContext.SaveChanges();
             //content.Text = String.Format( "<div class='alert alert-success'>Your recurring {0} has been deleted.</div>", GetAttributeValue( "TransactionLabel" ).ToLower() );
         }
         else
         {
             //content.Text = String.Format( "<div class='alert alert-danger'>An error occured while deleting your scheduled transation. Message: {0}</div>", errorMessage );
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// Handles the Click event of the lbCancelSchedule 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 lbCancelSchedule_Click( object sender, EventArgs e )
        {
            int? txnId = PageParameter( "ScheduledTransactionId" ).AsIntegerOrNull();
            if ( txnId.HasValue )
            {
                using ( var rockContext = new RockContext() )
                {
                    var txnService = new FinancialScheduledTransactionService( rockContext );
                    var txn = txnService
                        .Queryable( "AuthorizedPersonAlias.Person,FinancialGateway" )
                        .FirstOrDefault( t => t.Id == txnId.Value );
                    if ( txn != null )
                    {
                        if ( txn.FinancialGateway != null )
                        {
                            txn.FinancialGateway.LoadAttributes( rockContext );
                        }

                        string errorMessage = string.Empty;
                        if ( txnService.Cancel( txn, out errorMessage ) )
                        {
                            txnService.GetStatus( txn, out errorMessage );
                            rockContext.SaveChanges();
                        }
                        else
                        {
                            ShowErrorMessage( errorMessage );
                        }

                        ShowView( txn );
                    }
                }
            }
        }
        /// <summary>
        /// Handles the Click event of the lbCancel 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 lbCancel_Click( object sender, EventArgs e )
        {
            int? txnId = PageParameter( "ScheduledTransactionId" ).AsIntegerOrNull();
            if ( txnId.HasValue )
            {
                var rockContext = new RockContext();
                var txnService = new FinancialScheduledTransactionService( rockContext );
                var txn = txnService.Get( txnId.Value );
                if ( txn != null )
                {
                    string errorMessage = string.Empty;
                    if ( txnService.Cancel( txn, out errorMessage ) )
                    {
                        txnService.GetStatus( txn, out errorMessage );
                        rockContext.SaveChanges();
                    }
                    else
                    {
                        ShowErrorMessage( errorMessage );
                    }

                    ShowView( txn );
                }
            }
        }