Ejemplo n.º 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> 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);
            var attributeList = fakeGroupMember.Attributes.Select(a => a.Value).ToList();

            EntityHelper.AddEntityFieldsForAttributeList(entityAttributeFields, attributeList);

            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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the workflow attributes.
        /// </summary>
        /// <param name="workflowTypeId">The workflow type identifier.</param>
        /// <returns></returns>
        private List <EntityField> GetWorkflowAttributes(int?workflowTypeId)
        {
            List <EntityField> entityAttributeFields = new List <EntityField>();

            if (workflowTypeId.HasValue)
            {
                var fakeWorkflow = new Rock.Model.Workflow {
                    WorkflowTypeId = workflowTypeId.Value
                };
                Rock.Attribute.Helper.LoadAttributes(fakeWorkflow);
                var attributeList = fakeWorkflow.Attributes.Select(a => a.Value).ToList();
                EntityHelper.AddEntityFieldsForAttributeList(entityAttributeFields, attributeList);
            }

            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 workflow attributes.
        /// </summary>
        /// <param name="workflowTypeId">The workflow type identifier.</param>
        /// <returns></returns>
        private static List <EntityField> GetWorkflowAttributes(int?workflowTypeId)
        {
            List <EntityField> entityAttributeFields = new List <EntityField>();

            var fakeWorkflow = new Rock.Model.Workflow();

            if (workflowTypeId.HasValue)
            {
                fakeWorkflow.WorkflowTypeId = workflowTypeId.Value;
            }
            else
            {
                //// if no WorkflowTypeId was specified, just set the WorkflowTypeId to 0
                //// NOTE: There could be Workflow Attributes that are not specific to a WorkflowTypeId
                fakeWorkflow.WorkflowTypeId = 0;
            }

            Rock.Attribute.Helper.LoadAttributes(fakeWorkflow);
            var attributeList = fakeWorkflow.Attributes.Select(a => a.Value).ToList();

            EntityHelper.AddEntityFieldsForAttributeList(entityAttributeFields, attributeList);

            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);
        }