Exemple #1
0
 private void BuildEditControls(PersonBadge personBadge, bool setValues)
 {
     personBadge.LoadAttributes();
     phAttributes.Controls.Clear();
     Rock.Attribute.Helper.AddEditControls(personBadge, phAttributes, setValues, "", new List <string> {
         "Active", "Order"
     });
 }
Exemple #2
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            PersonBadge        PersonBadge        = null;
            var                rockContext        = new RockContext();
            PersonBadgeService PersonBadgeService = new PersonBadgeService(rockContext);

            if (PersonBadgeId != 0)
            {
                PersonBadge = PersonBadgeService.Get(PersonBadgeId);
            }

            if (PersonBadge == null)
            {
                PersonBadge = new PersonBadge();
                PersonBadgeService.Add(PersonBadge);
            }

            PersonBadge.Name        = tbName.Text;
            PersonBadge.Description = tbDescription.Text;

            if (!string.IsNullOrWhiteSpace(compBadgeType.SelectedValue))
            {
                var badgeType = EntityTypeCache.Read(compBadgeType.SelectedValue.AsGuid());
                if (badgeType != null)
                {
                    PersonBadge.EntityTypeId = badgeType.Id;
                }
            }

            PersonBadge.LoadAttributes(rockContext);
            Rock.Attribute.Helper.GetEditValues(phAttributes, PersonBadge);

            if (!Page.IsValid)
            {
                return;
            }

            if (!PersonBadge.IsValid)
            {
                return;
            }

            rockContext.WrapTransaction(() =>
            {
                rockContext.SaveChanges();
                PersonBadge.SaveAttributeValues(rockContext);
            });

            PersonBadgeCache.Flush(PersonBadge.Id);

            NavigateToParentPage();
        }
Exemple #3
0
 /// <summary>
 /// Loads the attributes for the badge.  The attributes are loaded by the framework prior to executing the badge, 
 /// so typically Person Badges do not need to load the attributes
 /// </summary>
 /// <param name="badge">The badge.</param>
 public void LoadAttributes( PersonBadge badge )
 {
     badge.LoadAttributes();
 }
 private void BuildEditControls(PersonBadge personBadge, bool setValues)
 {
     personBadge.LoadAttributes();
     phAttributes.Controls.Clear();
     Rock.Attribute.Helper.AddEditControls( personBadge, phAttributes, setValues, "", new List<string> { "Active", "Order" } );
 }
Exemple #5
0
 /// <summary>
 /// Loads the attributes for the badge.  The attributes are loaded by the framework prior to executing the badge,
 /// so typically Person Badges do not need to load the attributes
 /// </summary>
 /// <param name="badge">The badge.</param>
 public void LoadAttributes(PersonBadge badge)
 {
     badge.LoadAttributes();
 }