コード例 #1
0
ファイル: CategoriesFieldType.cs プロジェクト: Ganon11/Rock
        /// <summary>
        /// Reads new values entered by the user for the field
        /// </summary>
        /// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <returns></returns>
        public override string GetEditValue( Control control, Dictionary<string, ConfigurationValue> configurationValues )
        {
            var picker = control as CategoryPicker;
            string result = null;

            if ( picker != null )
            {
                var guids = new List<Guid>();
                var ids = picker.SelectedValuesAsInt();
                var categories = new CategoryService( new RockContext() ).Queryable().Where( c => ids.Contains( c.Id ) );

                if ( categories.Any() )
                {
                    guids = categories.Select( c => c.Guid ).ToList();
                }

                result = string.Join( ",", guids );

            }

            return result;
        }