本文整理汇总了C#中Rock.Model.PersonService.GetBusinesses方法的典型用法代码示例。如果您正苦于以下问题:C# PersonService.GetBusinesses方法的具体用法?C# PersonService.GetBusinesses怎么用?C# PersonService.GetBusinesses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.PersonService
的用法示例。
在下文中一共展示了PersonService.GetBusinesses方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetGiveAsOptions
/// <summary>
/// Sets the give as options.
/// </summary>
private void SetGiveAsOptions()
{
bool showBusinessOption = CurrentPerson != null && phGiveAsOption.Visible && !tglGiveAsOption.Checked;
phGiveAsPerson.Visible = !showBusinessOption;
phGiveAsBusiness.Visible = showBusinessOption;
if ( showBusinessOption )
{
if ( hfBusinessesLoaded.ValueAsInt() != CurrentPerson.Id )
{
cblBusiness.Items.Clear();
using ( var rockContext = new RockContext() )
{
var personService = new PersonService( rockContext );
var businesses = personService.GetBusinesses( CurrentPerson.Id ).ToList();
if ( businesses.Any() )
{
foreach ( var business in businesses )
{
cblBusiness.Items.Add( new ListItem( business.LastName, business.Id.ToString() ) );
}
cblBusiness.Items.Add( new ListItem( "New Business", "" ) );
cblBusiness.Visible = true;
if ( _scheduledTransactionToBeTransferred != null )
{
var matchBusiness = businesses.Where( b => b.Id == _scheduledTransactionToBeTransferred.AuthorizedPersonAlias.PersonId ).FirstOrDefault();
if ( matchBusiness != null )
{
cblBusiness.SetValue( matchBusiness.Id.ToString() );
}
}
else
{
cblBusiness.SelectedIndex = 0;
}
}
else
{
cblBusiness.Visible = false;
}
}
hfBusinessesLoaded.Value = CurrentPerson.Id.ToString();
}
lPersonalInfoTitle.Text = "Business Information";
}
else
{
lPersonalInfoTitle.Text = GetAttributeValue( "PersonalInfoTitle" );
}
}
示例2: GetScheduledTransaction
/// <summary>
/// Gets the scheduled transaction.
/// </summary>
/// <param name="refresh">if set to <c>true</c> [refresh].</param>
/// <returns></returns>
private FinancialScheduledTransaction GetScheduledTransaction( bool refresh = false )
{
Person targetPerson = null;
using ( var rockContext = new RockContext() )
{
// If impersonation is allowed, and a valid person key was used, set the target to that person
bool allowImpersonation = GetAttributeValue( "Impersonation" ).AsBoolean();
if ( allowImpersonation )
{
string personKey = PageParameter( "Person" );
if ( !string.IsNullOrWhiteSpace( personKey ) )
{
targetPerson = new PersonService( rockContext ).GetByUrlEncodedKey( personKey );
}
}
if ( targetPerson == null )
{
targetPerson = CurrentPerson;
}
// Verify that transaction id is valid for selected person
if ( targetPerson != null )
{
int txnId = int.MinValue;
if ( int.TryParse( PageParameter( "ScheduledTransactionId" ), out txnId ) )
{
var personService = new PersonService( rockContext );
var validGivingIds = new List<string> { targetPerson.GivingId };
validGivingIds.AddRange( personService.GetBusinesses( targetPerson.Id ).Select( b => b.GivingId ) );
var service = new FinancialScheduledTransactionService( rockContext );
var scheduledTransaction = service
.Queryable( "AuthorizedPersonAlias.Person,ScheduledTransactionDetails,FinancialGateway,FinancialPaymentDetail.CurrencyTypeValue,FinancialPaymentDetail.CreditCardTypeValue" )
.Where( t =>
t.Id == txnId &&
t.AuthorizedPersonAlias != null &&
t.AuthorizedPersonAlias.Person != null &&
validGivingIds.Contains( t.AuthorizedPersonAlias.Person.GivingId ) )
.FirstOrDefault();
if ( scheduledTransaction != null )
{
if ( scheduledTransaction.AuthorizedPersonAlias != null )
{
TargetPersonId = scheduledTransaction.AuthorizedPersonAlias.PersonId;
}
ScheduledTransactionId = scheduledTransaction.Id;
if ( scheduledTransaction.FinancialGateway != null )
{
scheduledTransaction.FinancialGateway.LoadAttributes( rockContext );
}
if ( refresh )
{
string errorMessages = string.Empty;
service.GetStatus( scheduledTransaction, out errorMessages );
rockContext.SaveChanges();
}
return scheduledTransaction;
}
}
}
}
return null;
}
示例3: InitializeTransfer
/// <summary>
/// Fetches the old (to be transferred) scheduled transaction and verifies
/// that the target person is the same on the scheduled transaction. Then
/// it puts it into the _scheduledTransactionToBeTransferred private field
/// for use throughout the entry process so that its values can be used on
/// the form for the new transaction.
/// </summary>
/// <param name="scheduledTransactionId">The scheduled transaction identifier.</param>
private void InitializeTransfer( int? scheduledTransactionId )
{
if ( scheduledTransactionId == null )
{
return;
}
RockContext rockContext = new RockContext();
var scheduledTransaction = new FinancialScheduledTransactionService( rockContext ).Get( scheduledTransactionId.Value );
var personService = new PersonService( rockContext );
// get business giving id
var givingIds = personService.GetBusinesses( _targetPerson.Id ).Select( g => g.GivingId ).ToList();
// add the person's regular giving id
givingIds.Add( _targetPerson.GivingId );
// Make sure the current person is the authorized person, otherwise return
if ( scheduledTransaction == null || ! givingIds.Contains( scheduledTransaction.AuthorizedPersonAlias.Person.GivingId ) )
{
return;
}
_scheduledTransactionToBeTransferred = scheduledTransaction;
// Set the frequency to be the same on the initial page build
if ( !IsPostBack )
{
btnFrequency.SelectedValue = scheduledTransaction.TransactionFrequencyValueId.ToString();
dtpStartDate.SelectedDate = ( scheduledTransaction.NextPaymentDate.HasValue ) ? scheduledTransaction.NextPaymentDate : RockDateTime.Today.AddDays( 1 );
}
}
示例4: ShowContent
// helper functional methods (like BindGrid(), etc.)
private void ShowContent()
{
// get scheduled contributions for current user
if ( CurrentPerson != null )
{
var rockContext = new RockContext();
var transactionService = new FinancialScheduledTransactionService( rockContext );
var personService = new PersonService( rockContext );
// get business giving id
var givingIds = personService.GetBusinesses( CurrentPerson.Id ).Select( g => g.GivingId ).ToList();
// add the person's regular giving id
givingIds.Add( CurrentPerson.GivingId );
var schedules = transactionService.Queryable( "ScheduledTransactionDetails.Account" )
.Where( s => givingIds.Contains( s.AuthorizedPersonAlias.Person.GivingId ) && s.IsActive == true );
// filter the list if necesssary
var gatewayFilterGuid = GetAttributeValue( "GatewayFilter" ).AsGuidOrNull();
if ( gatewayFilterGuid != null )
{
schedules = schedules.Where( s => s.FinancialGateway.Guid == gatewayFilterGuid );
}
rptScheduledTransactions.DataSource = schedules.ToList();
rptScheduledTransactions.DataBind();
if ( schedules.Count() == 0 )
{
pnlNoScheduledTransactions.Visible = true;
lNoScheduledTransactionsMessage.Text = string.Format("No {0} currently exist.", GetAttributeValue("TransactionLabel").Pluralize().ToLower());
}
}
}