本文整理汇总了C#中Rock.Model.GroupService.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# GroupService.Contains方法的具体用法?C# GroupService.Contains怎么用?C# GroupService.Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupService
的用法示例。
在下文中一共展示了GroupService.Contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindGroupPlacementGrid
/// <summary>
/// Binds the group placement grid.
/// </summary>
/// <param name="isExporting">if set to <c>true</c> [is exporting].</param>
private void BindGroupPlacementGrid( bool isExporting = false )
{
int? groupId = gpGroupPlacementParentGroup.SelectedValueAsInt();
int? instanceId = hfRegistrationInstanceId.Value.AsIntegerOrNull();
if ( instanceId.HasValue )
{
using ( var rockContext = new RockContext() )
{
// Start query for registrants
var qry = new RegistrationRegistrantService( rockContext )
.Queryable( "PersonAlias.Person.PhoneNumbers.NumberTypeValue,Fees.RegistrationTemplateFee,GroupMember.Group" ).AsNoTracking()
.Where( r =>
r.Registration.RegistrationInstanceId == instanceId.Value &&
r.PersonAlias != null &&
r.PersonAlias.Person != null );
if ( groupId.HasValue )
{
var validGroupIds = new GroupService( rockContext ).GetAllDescendents( groupId.Value )
.Select( g => g.Id )
.ToList();
var existingPeopleInGroups = new GroupMemberService( rockContext )
.Queryable().AsNoTracking()
.Where( m => validGroupIds.Contains( m.GroupId ) )
.Select( m => m.PersonId )
.ToList();
qry = qry.Where( r => !existingPeopleInGroups.Contains( r.PersonAlias.PersonId ) );
}
bool preloadCampusValues = false;
var registrantAttributeIds = new List<int>();
var personAttributesIds = new List<int>();
var groupMemberAttributesIds = new List<int>();
if ( RegistrantFields != null )
{
// Check if campus is used
preloadCampusValues = RegistrantFields
.Any( f =>
f.FieldSource == RegistrationFieldSource.PersonField &&
f.PersonFieldType.HasValue &&
f.PersonFieldType.Value == RegistrationPersonFieldType.Campus );
// Get all the registrant attributes selected
var registrantAttributes = RegistrantFields
.Where( f =>
f.Attribute != null &&
f.FieldSource == RegistrationFieldSource.RegistrationAttribute )
.Select( f => f.Attribute )
.ToList();
registrantAttributeIds = registrantAttributes.Select( a => a.Id ).Distinct().ToList();
// Get all the person attributes selected
var personAttributes = RegistrantFields
.Where( f =>
f.Attribute != null &&
f.FieldSource == RegistrationFieldSource.PersonAttribute )
.Select( f => f.Attribute )
.ToList();
personAttributesIds = personAttributes.Select( a => a.Id ).Distinct().ToList();
// Get all the group member attributes selected to be on grid
var groupMemberAttributes = RegistrantFields
.Where( f =>
f.Attribute != null &&
f.FieldSource == RegistrationFieldSource.GroupMemberAttribute )
.Select( f => f.Attribute )
.ToList();
groupMemberAttributesIds = groupMemberAttributes.Select( a => a.Id ).Distinct().ToList();
}
// Sort the query
IOrderedQueryable<RegistrationRegistrant> orderedQry = null;
SortProperty sortProperty = gGroupPlacements.SortProperty;
if ( sortProperty != null )
{
orderedQry = qry.Sort( sortProperty );
}
else
{
orderedQry = qry
.OrderBy( r => r.PersonAlias.Person.LastName )
.ThenBy( r => r.PersonAlias.Person.NickName );
}
// Set the grids LinqDataSource which will run query and set results for current page
gGroupPlacements.SetLinqDataSource<RegistrationRegistrant>( orderedQry );
if ( RegistrantFields != null )
{
// Get the query results for the current page
var currentPageRegistrants = gGroupPlacements.DataSource as List<RegistrationRegistrant>;
if ( currentPageRegistrants != null )
{
//.........这里部分代码省略.........
示例2: BindGroupMembersGrid
/// <summary>
/// Binds the group members grid.
/// </summary>
protected void BindGroupMembersGrid()
{
if ( _group != null )
{
pnlGroupMembers.Visible = true;
lHeading.Text = string.Format( "{0} {1}", _group.GroupType.GroupTerm, _group.GroupType.GroupMemberTerm.Pluralize() );
if ( _group.GroupType.Roles.Any() )
{
nbRoleWarning.Visible = false;
rFilter.Visible = true;
gGroupMembers.Visible = true;
var rockContext = new RockContext();
GroupMemberService groupMemberService = new GroupMemberService( rockContext );
var qry = groupMemberService.Queryable( "Person,GroupRole", true ).AsNoTracking()
.Where( m => m.GroupId == _group.Id );
// Filter by First Name
string firstName = tbFirstName.Text;
if ( !string.IsNullOrWhiteSpace( firstName ) )
{
qry = qry.Where( m => m.Person.FirstName.StartsWith( firstName ) );
}
// Filter by Last Name
string lastName = tbLastName.Text;
if ( !string.IsNullOrWhiteSpace( lastName ) )
{
qry = qry.Where( m => m.Person.LastName.StartsWith( lastName ) );
}
// Filter by role
var validGroupTypeRoles = _group.GroupType.Roles.Select( r => r.Id ).ToList();
var roles = new List<int>();
foreach ( string role in cblRole.SelectedValues )
{
if ( !string.IsNullOrWhiteSpace( role ) )
{
int roleId = int.MinValue;
if ( int.TryParse( role, out roleId ) && validGroupTypeRoles.Contains( roleId ) )
{
roles.Add( roleId );
}
}
}
if ( roles.Any() )
{
qry = qry.Where( m => roles.Contains( m.GroupRoleId ) );
}
// Filter by Status
var statuses = new List<GroupMemberStatus>();
foreach ( string status in cblStatus.SelectedValues )
{
if ( !string.IsNullOrWhiteSpace( status ) )
{
statuses.Add( status.ConvertToEnum<GroupMemberStatus>() );
}
}
if ( statuses.Any() )
{
qry = qry.Where( m => statuses.Contains( m.GroupMemberStatus ) );
}
// Filter query by any configured attribute filters
if ( AvailableAttributes != null && AvailableAttributes.Any() )
{
var attributeValueService = new AttributeValueService( rockContext );
var parameterExpression = attributeValueService.ParameterExpression;
foreach ( var attribute in AvailableAttributes )
{
var filterControl = phAttributeFilters.FindControl( "filter_" + attribute.Id.ToString() );
if ( filterControl != null )
{
var filterValues = attribute.FieldType.Field.GetFilterValues( filterControl, attribute.QualifierValues, Rock.Reporting.FilterMode.SimpleFilter );
var expression = attribute.FieldType.Field.AttributeFilterExpression( attribute.QualifierValues, filterValues, parameterExpression );
if ( expression != null )
{
var attributeValues = attributeValueService
.Queryable()
.Where( v => v.Attribute.Id == attribute.Id );
attributeValues = attributeValues.Where( parameterExpression, expression, null );
qry = qry.Where( w => attributeValues.Select( v => v.EntityId ).Contains( w.Id ) );
}
}
}
}
_inactiveStatus = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_INACTIVE );
//.........这里部分代码省略.........
示例3: BindGroupMembersGrid
/// <summary>
/// Binds the group members grid.
/// </summary>
protected void BindGroupMembersGrid( bool isExporting = false )
{
if ( _group != null )
{
pnlGroupMembers.Visible = true;
lHeading.Text = string.Format( "{0} {1}", _group.GroupType.GroupTerm, _group.GroupType.GroupMemberTerm.Pluralize() );
if ( _group.GroupType.Roles.Any() )
{
nbRoleWarning.Visible = false;
rFilter.Visible = true;
gGroupMembers.Visible = true;
var rockContext = new RockContext();
if ( _group != null &&
_group.RequiredSignatureDocumentTemplateId.HasValue )
{
Signers = new SignatureDocumentService( rockContext )
.Queryable().AsNoTracking()
.Where( d =>
d.SignatureDocumentTemplateId == _group.RequiredSignatureDocumentTemplateId.Value &&
d.Status == SignatureDocumentStatus.Signed &&
d.BinaryFileId.HasValue &&
d.AppliesToPersonAlias != null )
.OrderByDescending( d => d.LastStatusDate )
.Select( d => d.AppliesToPersonAlias.PersonId )
.ToList();
}
GroupMemberService groupMemberService = new GroupMemberService( rockContext );
var qry = groupMemberService.Queryable( "Person,GroupRole", true ).AsNoTracking()
.Where( m => m.GroupId == _group.Id );
// Filter by First Name
string firstName = tbFirstName.Text;
if ( !string.IsNullOrWhiteSpace( firstName ) )
{
qry = qry.Where( m =>
m.Person.FirstName.StartsWith( firstName ) ||
m.Person.NickName.StartsWith( firstName ) );
}
// Filter by Last Name
string lastName = tbLastName.Text;
if ( !string.IsNullOrWhiteSpace( lastName ) )
{
qry = qry.Where( m => m.Person.LastName.StartsWith( lastName ) );
}
// Filter by role
var validGroupTypeRoles = _group.GroupType.Roles.Select( r => r.Id ).ToList();
var roles = new List<int>();
foreach ( var roleId in cblRole.SelectedValues.AsIntegerList() )
{
if ( validGroupTypeRoles.Contains( roleId ) )
{
roles.Add( roleId );
}
}
if ( roles.Any() )
{
qry = qry.Where( m => roles.Contains( m.GroupRoleId ) );
}
// Filter by Group Member Status
var statuses = new List<GroupMemberStatus>();
foreach ( string status in cblGroupMemberStatus.SelectedValues )
{
if ( !string.IsNullOrWhiteSpace( status ) )
{
statuses.Add( status.ConvertToEnum<GroupMemberStatus>() );
}
}
if ( statuses.Any() )
{
qry = qry.Where( m => statuses.Contains( m.GroupMemberStatus ) );
}
var genders = new List<Gender>();
foreach ( var item in cblGenderFilter.SelectedValues )
{
var gender = item.ConvertToEnum<Gender>();
genders.Add( gender );
}
if ( genders.Any() )
{
qry = qry.Where( m => genders.Contains( m.Person.Gender ) );
}
// Filter by Campus
if ( cpCampusFilter.SelectedCampusId.HasValue )
{
//.........这里部分代码省略.........