Example #1
0
        /// <summary>
        /// Reloads the attribute values.
        /// </summary>
        public virtual void ReloadAttributeValues()
        {
            var service = new Rock.Data.Service <T>();
            var model   = service.Get(this.Id);

            if (model != null)
            {
                model.LoadAttributes();

                this.AttributeValues = model.AttributeValues;
                this.Attributes      = model.Attributes;
            }
        }
Example #2
0
        /// <summary>
        /// Saves the attribute values.
        /// </summary>
        /// <param name="personId">The person id.</param>
        public virtual void SaveAttributeValues(int?personId)
        {
            var service = new Rock.Data.Service <T>();
            var model   = service.Get(this.Id);

            if (model != null)
            {
                model.LoadAttributes();
                foreach (var attribute in model.Attributes)
                {
                    if (this.AttributeValues.ContainsKey(attribute.Key))
                    {
                        Rock.Attribute.Helper.SaveAttributeValues(model, attribute.Value, this.AttributeValues[attribute.Key], personId);
                    }
                }
            }
        }