本文整理汇总了C#中Rock.Model.GroupService.GetAttributeValue方法的典型用法代码示例。如果您正苦于以下问题:C# GroupService.GetAttributeValue方法的具体用法?C# GroupService.GetAttributeValue怎么用?C# GroupService.GetAttributeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupService
的用法示例。
在下文中一共展示了GroupService.GetAttributeValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowDetail
/// <summary>
/// Shows the detail.
/// </summary>
private void ShowDetail()
{
var rockContext = new RockContext();
var groupMemberService = new GroupMemberService( rockContext );
var attributeValueService = new AttributeValueService( rockContext );
if ( CurrentPerson != null )
{
var personId = CurrentPerson.Id;
// Setup Image
string imgTag = Rock.Model.Person.GetPersonPhotoImageTag( CurrentPerson, 200, 200 );
if ( CurrentPerson.PhotoId.HasValue )
{
lImage.Text = string.Format( "<a href='{0}'>{1}</a>", CurrentPerson.PhotoUrl, imgTag );
}
else
{
lImage.Text = imgTag;
}
// Person Info
lName.Text = CurrentPerson.FullName;
if ( CurrentPerson.BirthDate.HasValue )
{
lAge.Text = string.Format( "{0}<small>({1})</small><br/>", CurrentPerson.FormatAge(), CurrentPerson.BirthYear != DateTime.MinValue.Year ? CurrentPerson.BirthDate.Value.ToShortDateString() : CurrentPerson.BirthDate.Value.ToMonthDayString() );
}
lGender.Text = CurrentPerson.Gender != Gender.Unknown ? CurrentPerson.Gender.ToString() : string.Empty;
lGrade.Text = CurrentPerson.GradeFormatted;
lMaritalStatus.Text = CurrentPerson.MaritalStatusValueId.DefinedValue();
if ( CurrentPerson.AnniversaryDate.HasValue )
{
lMaritalStatus.Text += string.Format( " {0} yrs <small>({1})</small>", CurrentPerson.AnniversaryDate.Value.Age(), CurrentPerson.AnniversaryDate.Value.ToMonthDayString() );
}
if ( CurrentPerson.GetFamilies().Count() > 1 )
{
ddlGroup.Visible = true;
}
// Contact Info
if ( CurrentPerson.PhoneNumbers != null )
{
var selectedPhoneTypeGuids = GetAttributeValue( "PhoneNumbers" ).Split( ',' ).AsGuidList();
rptPhones.DataSource = CurrentPerson.PhoneNumbers.Where( pn => selectedPhoneTypeGuids.Contains( pn.NumberTypeValue.Guid ) ).ToList();
rptPhones.DataBind();
}
lEmail.Text = CurrentPerson.Email;
// Person Attributes
List<Guid> attributeGuidList = GetPersonAttributeGuids( personId );
CurrentPerson.LoadAttributes();
rptPersonAttributes.DataSource = CurrentPerson.Attributes.Where( a =>
attributeGuidList.Contains( a.Value.Guid ) )
.Select( a => new
{
Name = a.Value.Name,
Value = a.Value.FieldType.Field.FormatValue( null, CurrentPerson.GetAttributeValue( a.Key ), a.Value.QualifierValues, a.Value.FieldType.Class == typeof( Rock.Field.Types.ImageFieldType ).FullName )
} )
.OrderBy( av => av.Name )
.ToList()
.Where( av => !String.IsNullOrWhiteSpace( av.Value ) );
rptPersonAttributes.DataBind();
// Families
if ( GetAttributeValue( "ShowFamilyMembers" ).AsBoolean() )
{
if ( ddlGroup.SelectedValueAsId().HasValue )
{
var group = new GroupService( rockContext ).Get( ddlGroup.SelectedValueAsId().Value );
if ( group != null )
{
// Family Name
lGroupName.Text = group.Name;
// Family Address
Guid? locationTypeGuid = GetAttributeValue( "AddressType" ).AsGuidOrNull();
if ( locationTypeGuid.HasValue )
{
var addressTypeDv = DefinedValueCache.Read( locationTypeGuid.Value );
var familyGroupTypeGuid = Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY.AsGuidOrNull();
if ( familyGroupTypeGuid.HasValue )
{
var familyGroupType = GroupTypeCache.Read( familyGroupTypeGuid.Value );
var address = new GroupLocationService( rockContext ).Queryable()
.Where( l => l.Group.GroupTypeId == familyGroupType.Id
&& l.GroupLocationTypeValueId == addressTypeDv.Id
&& l.Group.Members.Any( m => m.PersonId == CurrentPerson.Id )
&& l.Group.Id == group.Id )
.Select( l => l.Location )
.FirstOrDefault();
//.........这里部分代码省略.........