Пример #1
0
        /// <summary>
        ///     Populates the group roles.
        /// </summary>
        /// <param name="checkboxList"></param>
        /// <param name="groupTypeGuid"></param>
        private void PopulateRelationshipTypesSelector(RockCheckBoxList checkboxList, Guid?groupTypeGuid)
        {
            bool showSelector = false;

            checkboxList.Items.Clear();

            var groupType = GroupTypeCache.Read(groupTypeGuid.GetValueOrDefault());

            if (groupType != null)
            {
                var selectableRoles = new GroupTypeRoleService(new RockContext()).GetByGroupTypeId(groupType.Id);

                // Exclude the Owner Role from the list of selectable Roles because a Person cannot be related to themselves.
                var ownerGuid = GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_OWNER.AsGuid();

                selectableRoles = selectableRoles.Where(x => x.Guid != ownerGuid);

                checkboxList.Items.Clear();

                foreach (var item in selectableRoles)
                {
                    checkboxList.Items.Add(new ListItem(item.Name, item.Guid.ToString()));
                }

                showSelector = checkboxList.Items.Count > 0;
            }

            checkboxList.Visible = showSelector;
        }