/// <summary> /// Loads the drop downs. /// </summary> public void LoadDropDowns() { // get accounts that are both allowed by the BlockSettings and also in the personal AccountList setting var rockContext = new RockContext(); var accountGuidList = GetAttributeValue("Accounts").SplitDelimitedValues().Select(a => a.AsGuid()); string keyPrefix = string.Format("transaction-matching-{0}-", this.BlockId); var personalAccountGuidList = (this.GetUserPreference(keyPrefix + "account-list") ?? string.Empty).SplitDelimitedValues().Select(a => a.AsGuid()).ToList(); var accountQry = new FinancialAccountService(rockContext) .Queryable() .Where(a => a.IsActive); // no accounts specified means "all Active" if (accountGuidList.Any()) { accountQry = accountQry.Where(a => accountGuidList.Contains(a.Guid)); } // no personal accounts specified means "all(that are allowed in block settings)" if (personalAccountGuidList.Any()) { accountQry = accountQry.Where(a => personalAccountGuidList.Contains(a.Guid)); } rptAccounts.DataSource = accountQry.OrderBy(a => a.Order).ThenBy(a => a.Name).ToList(); rptAccounts.DataBind(); }
/// <summary> /// Loads the drop downs. /// </summary> public void LoadDropDowns() { // get accounts that are both allowed by the BlockSettings and also in the personal AccountList setting var rockContext = new RockContext(); var accountGuidList = GetAttributeValue( "Accounts" ).SplitDelimitedValues().Select( a => a.AsGuid() ); string keyPrefix = string.Format( "transaction-matching-{0}-", this.BlockId ); var personalAccountGuidList = ( this.GetUserPreference( keyPrefix + "account-list" ) ?? string.Empty ).SplitDelimitedValues().Select( a => a.AsGuid() ).ToList(); var accountQry = new FinancialAccountService( rockContext ).Queryable(); // no accounts specified means "all" if ( accountGuidList.Any() ) { accountQry = accountQry.Where( a => accountGuidList.Contains( a.Guid ) ); } // no personal accounts specified means "all(that are allowed in block settings)" if ( personalAccountGuidList.Any() ) { accountQry = accountQry.Where( a => personalAccountGuidList.Contains( a.Guid ) ); } rptAccounts.DataSource = accountQry.OrderBy( a => a.Order ).ThenBy( a => a.Name ).ToList(); rptAccounts.DataBind(); }