本文整理汇总了C#中Rock.Model.PersonService.GetFamilyMembers方法的典型用法代码示例。如果您正苦于以下问题:C# PersonService.GetFamilyMembers方法的具体用法?C# PersonService.GetFamilyMembers怎么用?C# PersonService.GetFamilyMembers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.PersonService
的用法示例。
在下文中一共展示了PersonService.GetFamilyMembers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowDetail
private void ShowDetail(Guid personGuid)
{
using ( var rockContext = new RockContext() )
{
var personService = new PersonService( rockContext );
var person = personService.Queryable( "PhoneNumbers.NumberTypeValue,RecordTypeValue", true, true )
.FirstOrDefault( a => a.Guid == personGuid );
if ( person != null )
{
lName.Text = person.FullName;
string photoTag = Rock.Model.Person.GetPersonPhotoImageTag( person, 120, 120 );
if ( person.PhotoId.HasValue )
{
lPhoto.Text = string.Format( "<div class='photoframe'><a href='{0}'>{1}</a></div>", person.PhotoUrl, photoTag );
}
else
{
lPhoto.Text = photoTag;
}
lGender.Text = person.Gender != Gender.Unknown ? person.Gender.ConvertToString() : "";
if ( person.BirthDate.HasValue )
{
string ageText = ( person.BirthYear.HasValue && person.BirthYear != DateTime.MinValue.Year ) ?
string.Format( "{0} yrs old ", person.BirthDate.Value.Age() ) : string.Empty;
lAge.Text = string.Format( "{0} <small>({1})</small><br/>", ageText, person.BirthDate.Value.ToShortDateString() );
}
else
{
lAge.Text = string.Empty;
}
lGrade.Text = person.GradeFormatted;
lEmail.Visible = !string.IsNullOrWhiteSpace( person.Email );
lEmail.Text = person.GetEmailTag( ResolveRockUrl( "/" ), "btn btn-default", "<i class='fa fa-envelope'></i>" );
// Get all family member from all families ( including self )
var allFamilyMembers = personService.GetFamilyMembers( person.Id, true ).ToList();
// Add flag for this person in each family indicating if they are a child in family.
var childGuid = Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_CHILD.AsGuid();
var isFamilyChild = new Dictionary<int, bool>();
foreach ( var thisPerson in allFamilyMembers.Where( m => m.PersonId == person.Id ) )
{
isFamilyChild.Add( thisPerson.GroupId, thisPerson.GroupRole.Guid.Equals( childGuid ) );
}
// Get the current url's root (without the person's guid)
string urlRoot = Request.Url.ToString().ReplaceCaseInsensitive( personGuid.ToString(), "" );
// Get the other family members and the info needed for rendering
var familyMembers = allFamilyMembers.Where( m => m.PersonId != person.Id )
.OrderBy( m => m.GroupId )
.ThenBy( m => m.Person.BirthDate )
.Select( m => new
{
Url = urlRoot + m.Person.Guid.ToString(),
FullName = m.Person.FullName,
Gender = m.Person.Gender,
FamilyRole = m.GroupRole,
Note = isFamilyChild[m.GroupId] ?
( m.GroupRole.Guid.Equals( childGuid ) ? " (Sibling)" : "(Parent)" ) :
( m.GroupRole.Guid.Equals( childGuid ) ? " (Child)" : "" )
} )
.ToList();
rcwFamily.Visible = familyMembers.Any();
rptrFamily.DataSource = familyMembers;
rptrFamily.DataBind();
rptrPhones.DataSource = person.PhoneNumbers.Where( p => !p.IsUnlisted ).ToList();
rptrPhones.DataBind();
var schedules = new ScheduleService( rockContext )
.Queryable().AsNoTracking()
.Where( s => s.CheckInStartOffsetMinutes.HasValue )
.ToList();
var scheduleIds = schedules.Select( s => s.Id ).ToList();
var activeScheduleIds = new List<int>();
foreach ( var schedule in schedules )
{
if ( schedule.IsScheduleOrCheckInActive )
{
activeScheduleIds.Add( schedule.Id );
}
}
int? personAliasId = person.PrimaryAliasId;
if ( !personAliasId.HasValue )
{
personAliasId = new PersonAliasService( rockContext ).GetPrimaryAliasId( person.Id );
}
//.........这里部分代码省略.........