本文整理汇总了C#中Rock.Model.GroupMemberService.DeleteRange方法的典型用法代码示例。如果您正苦于以下问题:C# GroupMemberService.DeleteRange方法的具体用法?C# GroupMemberService.DeleteRange怎么用?C# GroupMemberService.DeleteRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupMemberService
的用法示例。
在下文中一共展示了GroupMemberService.DeleteRange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnConfirm_Click
//.........这里部分代码省略.........
{
note.AllowPerson( Authorization.EDIT, CurrentPerson, rockContext );
if ( isPrivate )
{
note.MakePrivate( Authorization.VIEW, CurrentPerson, rockContext );
}
}
} );
}
}
#endregion
#region Group
int? groupId = gpGroup.SelectedValue.AsIntegerOrNull();
if ( groupId.HasValue )
{
var group = new GroupService( rockContext ).Get( groupId.Value );
if ( group != null )
{
var groupMemberService = new GroupMemberService( rockContext );
var existingMembers = groupMemberService.Queryable( "Group" )
.Where( m =>
m.GroupId == group.Id &&
ids.Contains( m.PersonId ) )
.ToList();
string action = ddlGroupAction.SelectedValue;
if ( action == "Remove" )
{
groupMemberService.DeleteRange( existingMembers );
rockContext.SaveChanges();
}
else
{
var roleId = ddlGroupRole.SelectedValueAsInt();
var status = ddlGroupMemberStatus.SelectedValueAsEnum<GroupMemberStatus>();
// Get the attribute values updated
var gm = new GroupMember();
gm.Group = group;
gm.GroupId = group.Id;
gm.LoadAttributes( rockContext );
var selectedGroupAttributes = new List<AttributeCache>();
var selectedGroupAttributeValues = new Dictionary<string, string>();
foreach ( var attributeCache in gm.Attributes.Select( a => a.Value ) )
{
Control attributeControl = phAttributes.FindControl( string.Format( "attribute_field_{0}", attributeCache.Id ) );
if ( attributeControl != null && ( action == "Add" || SelectedFields.Contains( attributeControl.ClientID ) ) )
{
string newValue = attributeCache.FieldType.Field.GetEditValue( attributeControl, attributeCache.QualifierValues );
selectedGroupAttributes.Add( attributeCache );
selectedGroupAttributeValues.Add( attributeCache.Key, newValue );
}
}
if ( action == "Add" )
{
if ( roleId.HasValue )
{
var newGroupMembers = new List<GroupMember>();
var existingIds = existingMembers.Select( m => m.PersonId ).Distinct().ToList();