本文整理汇总了C#中Rock.Model.GroupTypeRoleService.Where方法的典型用法代码示例。如果您正苦于以下问题:C# GroupTypeRoleService.Where方法的具体用法?C# GroupTypeRoleService.Where怎么用?C# GroupTypeRoleService.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupTypeRoleService
的用法示例。
在下文中一共展示了GroupTypeRoleService.Where方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRelationships
/// <summary>
/// Adds a KnownRelationship record between the two supplied Guids with the given 'is' relationship type:
///
/// Role / inverse Role
/// ================================
/// step-parent / step-child
/// grandparent / grandchild
/// previous-spouse / previous-spouse
/// can-check-in / allow-check-in-by
/// parent / child
/// sibling / sibling
/// invited / invited-by
/// related / related
///
/// ...for xml such as:
/// <relationships>
/// <relationship a="Ben" personGuid="3C402382-3BD2-4337-A996-9E62F1BAB09D"
/// has="step-parent" forGuid="3D7F6605-3666-4AB5-9F4E-D7FEBF93278E" name="Brian" />
/// </relationships>
///
/// </summary>
/// <param name="elemRelationships"></param>
private void AddRelationships( XElement elemRelationships, RockContext rockContext )
{
if ( elemRelationships == null )
{
return;
}
Guid ownerRoleGuid = Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_OWNER.AsGuid();
Guid knownRelationshipsGroupTypeGuid = Rock.SystemGuid.GroupType.GROUPTYPE_KNOWN_RELATIONSHIPS.AsGuid();
var memberService = new GroupMemberService( rockContext );
var groupTypeRoles = new GroupTypeRoleService( rockContext ).Queryable( "GroupType" )
.Where( r => r.GroupType.Guid == knownRelationshipsGroupTypeGuid ).ToList();
//// We have to create (or fetch existing) two groups for each relationship, adding the
//// other person as a member of that group with the appropriate GroupTypeRole (GTR):
//// * a group with person as owner (GTR) and forPerson as type/role (GTR)
//// * a group with forPerson as owner (GTR) and person as inverse-type/role (GTR)
foreach ( var elemRelationship in elemRelationships.Elements( "relationship" ) )
{
// skip any illegally formatted items
if ( elemRelationship.Attribute( "personGuid" ) == null || elemRelationship.Attribute( "forGuid" ) == null ||
elemRelationship.Attribute( "has" ) == null )
{
continue;
}
Guid personGuid = elemRelationship.Attribute( "personGuid" ).Value.Trim().AsGuid();
Guid forGuid = elemRelationship.Attribute( "forGuid" ).Value.Trim().AsGuid();
int ownerPersonId = _peopleDictionary[personGuid];
int forPersonId = _peopleDictionary[forGuid];
string relationshipType = elemRelationship.Attribute( "has" ).Value.Trim();
int roleId = -1;
switch ( relationshipType )
{
case "step-parent":
roleId = groupTypeRoles.Where( r => r.Guid == Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_STEP_PARENT.AsGuid() )
.Select( r => r.Id ).FirstOrDefault();
break;
case "step-child":
roleId = groupTypeRoles.Where( r => r.Guid == Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_STEP_CHILD.AsGuid() )
.Select( r => r.Id ).FirstOrDefault();
break;
case "can-check-in":
roleId = groupTypeRoles.Where( r => r.Guid == Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_CAN_CHECK_IN.AsGuid() )
.Select( r => r.Id ).FirstOrDefault();
break;
case "allow-check-in-by":
roleId = groupTypeRoles.Where( r => r.Guid == Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_ALLOW_CHECK_IN_BY.AsGuid() )
.Select( r => r.Id ).FirstOrDefault();
break;
case "grandparent":
roleId = groupTypeRoles.Where( r => r.Guid == Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_GRANDPARENT.AsGuid() )
.Select( r => r.Id ).FirstOrDefault();
break;
case "grandchild":
roleId = groupTypeRoles.Where( r => r.Guid == Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_GRANDCHILD.AsGuid() )
.Select( r => r.Id ).FirstOrDefault();
break;
case "invited":
roleId = groupTypeRoles.Where( r => r.Guid == Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_INVITED.AsGuid() )
.Select( r => r.Id ).FirstOrDefault();
break;
case "invited-by":
roleId = groupTypeRoles.Where( r => r.Guid == Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_INVITED_BY.AsGuid() )
.Select( r => r.Id ).FirstOrDefault();
break;
//.........这里部分代码省略.........