GetChildren() public method

Gets immediate children of a group (id) or a rootGroupId. Specify 0 for both Id and rootGroupId to get top level groups limited
public GetChildren ( int id, int rootGroupId, bool limitToSecurityRoleGroups, List groupTypeIncludedIds, List groupTypeExcludedIds, bool includeInactiveGroups, bool limitToShowInNavigation ) : IQueryable
id int The ID of the Group to get the children of (or 0 to use rootGroupId)
rootGroupId int The root group ID
limitToSecurityRoleGroups bool if set to true [limit to security role groups].
groupTypeIncludedIds List The group type included ids.
groupTypeExcludedIds List The group type excluded ids.
includeInactiveGroups bool if set to true [include inactive groups].
limitToShowInNavigation bool if set to true [limit to show in navigation].
return IQueryable
Esempio n. 1
0
        /// <summary>
        /// Finds the first group.
        /// </summary>
        /// <returns></returns>
        private Group FindFirstGroup()
        {
            var groupService = new GroupService( new RockContext() );
            var includedGroupTypeIds = hfGroupTypesInclude.Value.SplitDelimitedValues().AsIntegerList().Except( new List<int> { 0 } ).ToList();
            var excludedGroupTypeIds = hfGroupTypesExclude.Value.SplitDelimitedValues().AsIntegerList().Except( new List<int> { 0 } ).ToList();

            // if specific group types are specified, show the groups regardless of ShowInNavigation
            bool limitToShowInNavigation = !includedGroupTypeIds.Any();

            var qry = groupService.GetChildren( 0, hfRootGroupId.ValueAsInt(), hfLimitToSecurityRoleGroups.Value.AsBoolean(), includedGroupTypeIds, excludedGroupTypeIds, !tglHideInactiveGroups.Checked, limitToShowInNavigation );

            foreach ( var group in qry.OrderBy( g => g.Name ) )
            {
                // return first group they are authorized to view
                if ( group.IsAuthorized( Authorization.VIEW, CurrentPerson ) )
                {
                    return group;
                }
            }

            return null;
        }