本文整理汇总了C#中Rock.Model.PersonService.FirstOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# PersonService.FirstOrDefault方法的具体用法?C# PersonService.FirstOrDefault怎么用?C# PersonService.FirstOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.PersonService
的用法示例。
在下文中一共展示了PersonService.FirstOrDefault方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DisplayResults
private void DisplayResults()
{
RockContext rockContext = new RockContext();
var statementYear = RockDateTime.Now.Year;
if ( Request["StatementYear"] != null )
{
Int32.TryParse( Request["StatementYear"].ToString(), out statementYear );
}
FinancialTransactionDetailService financialTransactionDetailService = new FinancialTransactionDetailService( rockContext );
var qry = financialTransactionDetailService.Queryable().AsNoTracking()
.Where( t=> t.Transaction.AuthorizedPersonAlias.Person.GivingId == CurrentPerson.GivingId);
qry = qry.Where( t => t.Transaction.TransactionDateTime.Value.Year == statementYear );
if ( string.IsNullOrWhiteSpace( GetAttributeValue( "Accounts" ) ) )
{
qry = qry.Where( t => t.Account.IsTaxDeductible );
} else
{
var accountGuids = GetAttributeValue( "Accounts" ).Split( ',' ).Select( Guid.Parse ).ToList();
qry = qry.Where( t => accountGuids.Contains( t.Account.Guid ) );
}
qry = qry.OrderByDescending( t => t.Transaction.TransactionDateTime );
var mergeFields = new Dictionary<string, object>();
mergeFields.Add( "StatementStartDate", "1/1/" + statementYear.ToString() );
if ( statementYear == RockDateTime.Now.Year )
{
mergeFields.Add( "StatementEndDate", RockDateTime.Now );
}
else
{
mergeFields.Add( "StatementEndDate", "12/31/" + statementYear.ToString() );
}
var familyGroupTypeId = GroupTypeCache.Read( Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY ).Id;
var groupMemberQry = new GroupMemberService( rockContext ).Queryable().Where( m => m.Group.GroupTypeId == familyGroupTypeId );
// get giving group members in order by family role (adult -> child) and then gender (male -> female)
var givingGroup = new PersonService( rockContext ).Queryable().AsNoTracking()
.Where( p => p.GivingId == CurrentPerson.GivingId )
.GroupJoin(
groupMemberQry,
p => p.Id,
m => m.PersonId,
(p, m) => new {p, m})
.SelectMany( x => x.m.DefaultIfEmpty(), (y,z) => new { Person = y.p, GroupMember = z} )
.Select( p => new { FirstName = p.Person.NickName, LastName = p.Person.LastName, FamilyRoleOrder = p.GroupMember.GroupRole.Order, Gender = p.Person.Gender, PersonId = p.Person.Id } )
.DistinctBy(p => p.PersonId)
.OrderBy(p => p.FamilyRoleOrder).ThenBy(p => p.Gender)
.ToList();
// make a list of person ids in the giving group
List<int> givingGroupIdsOnly = new List<int>();
foreach ( var x in givingGroup )
{
givingGroupIdsOnly.Add(x.PersonId);
}
string salutation = string.Empty;
if (givingGroup.GroupBy(g => g.LastName).Count() == 1 )
{
salutation = string.Join( ", ", givingGroup.Select( g => g.FirstName ) ) + " " + givingGroup.FirstOrDefault().LastName;
if ( salutation.Contains( "," ) )
{
salutation = salutation.ReplaceLastOccurrence( ",", " &" );
}
}
else
{
salutation = string.Join( ", ", givingGroup.Select( g => g.FirstName + " " + g.LastName ) );
if ( salutation.Contains( "," ) )
{
salutation = salutation.ReplaceLastOccurrence( ",", " &" );
}
}
mergeFields.Add( "Salutation", salutation );
var homeAddress = CurrentPerson.GetHomeLocation();
if ( homeAddress != null )
{
mergeFields.Add( "StreetAddress1", homeAddress.Street1 );
mergeFields.Add( "StreetAddress2", homeAddress.Street2 );
mergeFields.Add( "City", homeAddress.City );
mergeFields.Add( "State", homeAddress.State );
mergeFields.Add( "PostalCode", homeAddress.PostalCode );
mergeFields.Add( "Country", homeAddress.Country );
}
else
{
mergeFields.Add( "StreetAddress1", string.Empty );
mergeFields.Add( "StreetAddress2", string.Empty );
mergeFields.Add( "City", string.Empty );
mergeFields.Add( "State", string.Empty );
//.........这里部分代码省略.........