Rock.Model.FinancialScheduledTransactionService.Get C# (CSharp) Method

Get() public method

Gets schedule transactions associated to a person. Includes any transactions associated to person or any other person with same giving group id
public Get ( int personId, int givingGroupId, bool includeInactive ) : IQueryable
personId int The person identifier.
givingGroupId int The giving group identifier.
includeInactive bool if set to true [include inactive].
return IQueryable
        public IQueryable<FinancialScheduledTransaction> Get( int? personId, int? givingGroupId, bool includeInactive )
        {
            var qry = Queryable()
                .Include( a => a.ScheduledTransactionDetails )
                .Include( a => a.FinancialPaymentDetail.CurrencyTypeValue )
                .Include( a => a.FinancialPaymentDetail.CreditCardTypeValue );

            if ( !includeInactive )
            {
                qry = qry.Where( t => t.IsActive );
            }

            if ( givingGroupId.HasValue )
            {
                //  Person contributes with family
                qry = qry.Where( t => t.AuthorizedPersonAlias.Person.GivingGroupId == givingGroupId );
            }
            else if ( personId.HasValue )
            {
                // Person contributes individually
                qry = qry.Where( t => t.AuthorizedPersonAlias.PersonId == personId );
            }

            return qry
                .OrderByDescending( t => t.IsActive )
                .ThenByDescending( t => t.StartDate );
        }

Usage Example

        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;
        }
All Usage Examples Of Rock.Model.FinancialScheduledTransactionService::Get