本文整理汇总了C#中Rock.Model.GroupMemberService.LoadAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# GroupMemberService.LoadAttributes方法的具体用法?C# GroupMemberService.LoadAttributes怎么用?C# GroupMemberService.LoadAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupMemberService
的用法示例。
在下文中一共展示了GroupMemberService.LoadAttributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowDetail
/// <summary>
/// Shows the detail.
/// </summary>
/// <param name="itemKey">The item key.</param>
/// <param name="itemKeyValue">The item key value.</param>
/// <param name="groupId">The group id.</param>
public void ShowDetail( string itemKey, int itemKeyValue, int? groupId )
{
if ( !itemKey.Equals( "GroupMemberId" ) )
{
return;
}
var rockContext = new RockContext();
GroupMember groupMember = null;
if ( !itemKeyValue.Equals( 0 ) )
{
groupMember = new GroupMemberService( rockContext ).Get( itemKeyValue );
groupMember.LoadAttributes();
}
else
{
// only create a new one if parent was specified
if ( groupId.HasValue )
{
groupMember = new GroupMember { Id = 0 };
groupMember.GroupId = groupId.Value;
groupMember.Group = new GroupService( rockContext ).Get( groupMember.GroupId );
groupMember.GroupRoleId = groupMember.Group.GroupType.DefaultGroupRoleId ?? 0;
groupMember.GroupMemberStatus = GroupMemberStatus.Active;
}
}
if ( groupMember == null )
{
return;
}
hfGroupId.Value = groupMember.GroupId.ToString();
hfGroupMemberId.Value = groupMember.Id.ToString();
// render UI based on Authorized and IsSystem
bool readOnly = false;
var group = groupMember.Group;
if ( !string.IsNullOrWhiteSpace( group.GroupType.IconCssClass ) )
{
lGroupIconHtml.Text = string.Format( "<i class='{0}' ></i>", group.GroupType.IconCssClass );
}
else
{
lGroupIconHtml.Text = string.Empty;
}
if ( groupMember.Id.Equals( 0 ) )
{
lReadOnlyTitle.Text = ActionTitle.Add( groupMember.Group.GroupType.GroupTerm + " " + groupMember.Group.GroupType.GroupMemberTerm ).FormatAsHtmlTitle();
}
else
{
lReadOnlyTitle.Text = groupMember.Person.FullName.FormatAsHtmlTitle();
}
// user has to have EDIT Auth to both the Block and the group
nbEditModeMessage.Text = string.Empty;
if ( !IsUserAuthorized( Authorization.EDIT ) || !group.IsAuthorized( Authorization.EDIT, this.CurrentPerson ) )
{
readOnly = true;
nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed( Group.FriendlyTypeName );
}
if ( groupMember.IsSystem )
{
readOnly = true;
nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem( Group.FriendlyTypeName );
}
btnSave.Visible = !readOnly;
LoadDropDowns();
ppGroupMemberPerson.SetValue( groupMember.Person );
ppGroupMemberPerson.Enabled = !readOnly;
ddlGroupRole.SetValue( groupMember.GroupRoleId );
ddlGroupRole.Enabled = !readOnly;
rblStatus.SetValue( (int)groupMember.GroupMemberStatus );
rblStatus.Enabled = !readOnly;
rblStatus.Label = string.Format( "{0} Status", group.GroupType.GroupMemberTerm );
groupMember.LoadAttributes();
phAttributes.Controls.Clear();
Rock.Attribute.Helper.AddEditControls( groupMember, phAttributes, true, "", true );
if ( readOnly )
{
Rock.Attribute.Helper.AddDisplayControls( groupMember, phAttributesReadOnly );
phAttributesReadOnly.Visible = true;
//.........这里部分代码省略.........
示例2: gpMoveGroupMember_SelectItem
/// <summary>
/// Handles the SelectItem event of the gpMoveGroupMember control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected void gpMoveGroupMember_SelectItem( object sender, EventArgs e )
{
var rockContext = new RockContext();
var destGroup = new GroupService( rockContext ).Get( gpMoveGroupMember.SelectedValue.AsInteger() );
if ( destGroup != null )
{
var destTempGroupMember = new GroupMember { Group = destGroup, GroupId = destGroup.Id };
destTempGroupMember.LoadAttributes( rockContext );
var destGroupMemberAttributes = destTempGroupMember.Attributes;
var groupMember = new GroupMemberService( rockContext ).Get( hfGroupMemberId.Value.AsInteger() );
groupMember.LoadAttributes();
var currentGroupMemberAttributes = groupMember.Attributes;
var lostAttributes = currentGroupMemberAttributes.Where( a => !destGroupMemberAttributes.Any( d => d.Key == a.Key && d.Value.FieldTypeId == a.Value.FieldTypeId ) );
nbMoveGroupMemberWarning.Visible = lostAttributes.Any();
nbMoveGroupMemberWarning.Text = "The destination group does not have the same group member attributes as the source. Some loss of data may occur";
if ( destGroup.Id == groupMember.GroupId )
{
grpMoveGroupMember.Visible = false;
nbMoveGroupMemberWarning.Visible = true;
nbMoveGroupMemberWarning.Text = "The destination group is the same as the current group";
}
else
{
grpMoveGroupMember.Visible = true;
grpMoveGroupMember.GroupTypeId = destGroup.GroupTypeId;
grpMoveGroupMember.GroupRoleId = destGroup.GroupType.DefaultGroupRoleId;
}
}
else
{
nbMoveGroupMemberWarning.Visible = false;
grpMoveGroupMember.Visible = false;
}
}