/// <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) { using (var rockContext = new RockContext()) { FollowingSuggestionType followingSuggestion = null; var eventService = new Rock.Model.FollowingSuggestionTypeService(rockContext); if (SuggestionId != 0) { followingSuggestion = eventService.Get(SuggestionId); } if (followingSuggestion == null) { followingSuggestion = new Rock.Model.FollowingSuggestionType(); eventService.Add(followingSuggestion); } followingSuggestion.Name = tbName.Text; followingSuggestion.IsActive = cbIsActive.Checked; followingSuggestion.Description = tbDescription.Text; followingSuggestion.EntityTypeId = cpSuggestionType.SelectedEntityTypeId; followingSuggestion.ReasonNote = tbReasonNote.Text; followingSuggestion.ReminderDays = nbReminderDays.Text.AsIntegerOrNull(); followingSuggestion.EntityNotificationFormatLava = ceNotificationFormat.Text; rockContext.SaveChanges(); followingSuggestion.LoadAttributes(rockContext); Rock.Attribute.Helper.GetEditValues(phAttributes, followingSuggestion); followingSuggestion.SaveAttributeValues(rockContext); } NavigateToParentPage(); }
/// <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 ) { using ( var rockContext = new RockContext() ) { FollowingSuggestionType followingSuggestion = null; var eventService = new Rock.Model.FollowingSuggestionTypeService( rockContext ); if ( SuggestionId != 0 ) { followingSuggestion = eventService.Get( SuggestionId ); } if ( followingSuggestion == null ) { followingSuggestion = new Rock.Model.FollowingSuggestionType(); eventService.Add( followingSuggestion ); } followingSuggestion.Name = tbName.Text; followingSuggestion.IsActive = cbIsActive.Checked; followingSuggestion.Description = tbDescription.Text; followingSuggestion.EntityTypeId = cpSuggestionType.SelectedEntityTypeId; followingSuggestion.ReasonNote = tbReasonNote.Text; followingSuggestion.ReminderDays = nbReminderDays.Text.AsIntegerOrNull(); followingSuggestion.EntityNotificationFormatLava = ceNotificationFormat.Text; rockContext.SaveChanges(); followingSuggestion.LoadAttributes( rockContext ); Rock.Attribute.Helper.GetEditValues( phAttributes, followingSuggestion ); followingSuggestion.SaveAttributeValues( rockContext ); } NavigateToParentPage(); }