Esempio n. 1
0
        /// <summary>
        /// Creates the control(s) necessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id)
        {
            int    entityTypeId    = 0;
            string qualifierColumn = string.Empty;
            string qualifierValue  = string.Empty;

            if (configurationValues != null)
            {
                if (configurationValues.ContainsKey(ENTITY_TYPE_NAME_KEY))
                {
                    string entityTypeName = configurationValues[ENTITY_TYPE_NAME_KEY].Value;
                    if (!string.IsNullOrWhiteSpace(entityTypeName) && entityTypeName != None.IdValue)
                    {
                        var entityType = EntityTypeCache.Read(entityTypeName);
                        if (entityType != null)
                        {
                            entityTypeId = entityType.Id;
                        }
                    }
                }
                if (configurationValues.ContainsKey(QUALIFIER_COLUMN_KEY))
                {
                    qualifierColumn = configurationValues[QUALIFIER_COLUMN_KEY].Value;
                }

                if (configurationValues.ContainsKey(QUALIFIER_VALUE_KEY))
                {
                    qualifierValue = configurationValues[QUALIFIER_VALUE_KEY].Value;
                }
            }

            RockCheckBoxList editControl = new RockCheckBoxList {
                ID = id
            };

            editControl.RepeatDirection = RepeatDirection.Horizontal;

            using (var rockContext = new RockContext())
            {
                var noteTypes = new NoteTypeService(rockContext).Get(entityTypeId, qualifierColumn, qualifierValue).ToList();
                if (noteTypes.Any())
                {
                    foreach (var noteType in noteTypes)
                    {
                        ListItem listItem = new ListItem(noteType.Name, noteType.Guid.ToString().ToUpper());
                        editControl.Items.Add(listItem);
                    }

                    return(editControl);
                }
            }

            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates the control(s) necessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override Control EditControl( Dictionary<string, ConfigurationValue> configurationValues, string id )
        {
            int entityTypeId = 0;
            string qualifierColumn = string.Empty;
            string qualifierValue = string.Empty;

            if ( configurationValues != null )
            {
                if ( configurationValues.ContainsKey( ENTITY_TYPE_NAME_KEY ) )
                {
                    string entityTypeName = configurationValues[ENTITY_TYPE_NAME_KEY].Value;
                    if ( !string.IsNullOrWhiteSpace( entityTypeName ) && entityTypeName != None.IdValue )
                    {
                        var entityType = EntityTypeCache.Read( entityTypeName );
                        if ( entityType != null )
                        {
                            entityTypeId = entityType.Id;
                        }
                    }
                }
                if ( configurationValues.ContainsKey( QUALIFIER_COLUMN_KEY ) )
                {
                    qualifierColumn = configurationValues[QUALIFIER_COLUMN_KEY].Value;
                }

                if ( configurationValues.ContainsKey( QUALIFIER_VALUE_KEY ) )
                {
                    qualifierValue = configurationValues[QUALIFIER_VALUE_KEY].Value;
                }
            }

            RockCheckBoxList editControl = new RockCheckBoxList { ID = id };
            editControl.RepeatDirection = RepeatDirection.Horizontal;

            using ( var rockContext = new RockContext() )
            {
                var noteTypes = new NoteTypeService( rockContext ).Get( entityTypeId, qualifierColumn, qualifierValue ).ToList();
                if ( noteTypes.Any() )
                {
                    foreach ( var noteType in noteTypes )
                    {
                        ListItem listItem = new ListItem( noteType.Name, noteType.Guid.ToString().ToUpper() );
                        editControl.Items.Add( listItem );
                    }

                    return editControl;
                }
            }

            return null;
        }