Beispiel #1
0
        /// <summary>
        /// Gets the defined values for the specified defined type as list items
        /// that can be sent to the client.
        /// </summary>
        /// <param name="definedTypeGuid">The defined type unique identifier.</param>
        /// <param name="options">The options that specify the behavior of which items to include.</param>
        /// <returns>A list of <see cref="ListItemViewModel"/> that represent the defined values.</returns>
        public List <ListItemViewModel> GetDefinedValuesAsListItems(Guid definedTypeGuid, DefinedValueOptions options = null)
        {
            var definedType = DefinedTypeCache.Get(definedTypeGuid, RockContext);

            if (definedType == null)
            {
                return(new List <ListItemViewModel>());
            }

            return(GetDefinedValuesAsListItems(definedType, options));
        }
Beispiel #2
0
        /// <summary>
        /// Gets the defined values for the specified defined type as list items
        /// that can be sent to the client.
        /// </summary>
        /// <param name="definedType">The defined type.</param>
        /// <param name="options">The options that specify the behavior of which items to include.</param>
        /// <returns>A list of <see cref="ListItemViewModel"/> that represent the defined values.</returns>
        public List <ListItemViewModel> GetDefinedValuesAsListItems(DefinedTypeCache definedType, DefinedValueOptions options = null)
        {
            IEnumerable <DefinedValueCache> source = definedType.DefinedValues;

            options = options ?? DefaultDefinedValueOptions;

            if (!options.IncludeInactive)
            {
                source = source.Where(v => v.IsActive);
            }

            source = CheckSecurity(source);

            return(source.OrderBy(v => v.Order)
                   .Select(v => new ListItemViewModel
            {
                Value = v.Guid.ToString(),
                Text = options.UseDescription ? v.Description : v.Value
            })
                   .ToList());
        }