Пример #1
0
        /// <summary>
        /// Gets the properties and attributes for the entity
        /// </summary>
        /// <param name="groupTypeId">The group type identifier.</param>
        /// <returns></returns>
        private List <EntityField> GetGroupAttributes(int?groupTypeId)
        {
            List <EntityField> entityAttributeFields = new List <EntityField>();

            if (groupTypeId.HasValue)
            {
                var fakeGroup = new Rock.Model.Group {
                    GroupTypeId = groupTypeId.Value
                };
                Rock.Attribute.Helper.LoadAttributes(fakeGroup);
                foreach (var attribute in fakeGroup.Attributes.Select(a => a.Value))
                {
                    EntityHelper.AddEntityFieldForAttribute(entityAttributeFields, attribute);
                }
            }

            int index        = 0;
            var sortedFields = new List <EntityField>();

            foreach (var entityProperty in entityAttributeFields.OrderBy(p => p.TitleWithoutQualifier).ThenBy(p => p.Name))
            {
                entityProperty.Index = index;
                index++;
                sortedFields.Add(entityProperty);
            }

            return(sortedFields);
        }
Пример #2
0
        /// <summary>
        /// Gets the properties and attributes for the entity
        /// </summary>
        /// <param name="contentChannelTypeId">The content channel type identifier.</param>
        /// <returns></returns>
        private List <EntityField> GetContentChannelItemAttributes(int?contentChannelTypeId)
        {
            List <EntityField> entityAttributeFields = new List <EntityField>();

            if (contentChannelTypeId.HasValue)
            {
                var fakeContentChannelItem = new Rock.Model.ContentChannelItem {
                    ContentChannelTypeId = contentChannelTypeId.Value
                };
                Rock.Attribute.Helper.LoadAttributes(fakeContentChannelItem);
                foreach (var attribute in fakeContentChannelItem.Attributes.Select(a => a.Value))
                {
                    EntityHelper.AddEntityFieldForAttribute(entityAttributeFields, attribute, true);
                }
            }

            int index        = 0;
            var sortedFields = new List <EntityField>();

            foreach (var entityProperty in entityAttributeFields.OrderBy(p => p.TitleWithoutQualifier).ThenBy(p => p.Name))
            {
                entityProperty.Index = index;
                index++;
                sortedFields.Add(entityProperty);
            }

            return(sortedFields);
        }
        /// <summary>
        /// Gets the properties and attributes for the entity
        /// </summary>
        /// <param name="groupTypeId">The group type identifier.</param>
        /// <returns></returns>
        private List <EntityField> GetGroupMemberAttributes(int?groupTypeId)
        {
            List <EntityField> entityAttributeFields = new List <EntityField>();

            var fakeGroupMember = new Rock.Model.GroupMember();

            fakeGroupMember.Group = new Rock.Model.Group();
            if (groupTypeId.HasValue)
            {
                fakeGroupMember.Group.GroupTypeId = groupTypeId.Value;
            }
            else
            {
                //// if no GroupTypeId was specified, just set the GroupTypeId to 0
                //// NOTE: There could be GroupMember Attributes that are not specific to a GroupType
                fakeGroupMember.Group.GroupTypeId = 0;
            }

            Rock.Attribute.Helper.LoadAttributes(fakeGroupMember);
            foreach (var attribute in fakeGroupMember.Attributes.Select(a => a.Value))
            {
                EntityHelper.AddEntityFieldForAttribute(entityAttributeFields, attribute);
            }

            int index        = 0;
            var sortedFields = new List <EntityField>();

            foreach (var entityProperty in entityAttributeFields.OrderBy(p => p.TitleWithoutQualifier).ThenBy(p => p.Name))
            {
                entityProperty.Index = index;
                index++;
                sortedFields.Add(entityProperty);
            }

            return(sortedFields);
        }