Esempio n. 1
0
        /// <summary>
        /// Gets the attribute values in a format that can be sent to remote
        /// clients in a compact and secure manner. This includes additional
        /// details to allow for editing the value.
        /// </summary>
        /// <param name="entity">The entity whose attributes are requested.</param>
        /// <param name="currentPerson">The current person.</param>
        /// <param name="enforceSecurity">if set to <c>true</c> then security will be enforced.</param>
        /// <returns>A collection of <see cref="ClientEditableAttributeValueViewModel" /> objects.</returns>
        public static List <ClientEditableAttributeValueViewModel> GetClientEditableAttributeValues(this IHasAttributes entity, Person currentPerson, bool enforceSecurity = true)
        {
            if (entity == null)
            {
                return(new List <ClientEditableAttributeValueViewModel>());
            }

            return(entity.AttributeValues
                   .Select(av => new
            {
                av.Value,
                Attribute = AttributeCache.Get(av.Value.AttributeId)
            })
                   .Where(av => !enforceSecurity || av.Attribute.IsAuthorized(Rock.Security.Authorization.VIEW, currentPerson))
                   .Select(kvp => ClientAttributeHelper.ToClientEditableAttributeValue(kvp.Value))
                   .ToList());
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the property values that will be sent to the device in the application bundle.
        /// </summary>
        /// <returns>
        /// A collection of string/object pairs.
        /// </returns>
        public override object GetMobileConfigurationValues()
        {
            using (var rockContext = new RockContext())
            {
                var attributes = AttributeFiltersGuids.Select(a => AttributeCache.Get(a))
                                 .Where(a => a != null)
                                 .Select(a => ClientAttributeHelper.ToClientEditableAttributeValue(a, a.DefaultValue))
                                 .ToList();

                return(new
                {
                    Campuses = GetValidCampuses(rockContext),
                    SearchHeader,
                    ShowCampusFilter,
                    ShowDayOfWeekFilter,
                    ShowTimePeriodFilter,
                    ShowLocationFilter,
                    ResultsTransition,
                    Attributes = attributes
                });
            }
        }