/// <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())
            {
                FollowingEventType followingEvent = null;

                var eventService = new Rock.Model.FollowingEventTypeService(rockContext);

                if (EventId != 0)
                {
                    followingEvent = eventService.Get(EventId);
                }

                if (followingEvent == null)
                {
                    followingEvent = new Rock.Model.FollowingEventType();
                    eventService.Add(followingEvent);
                }

                followingEvent.Name           = tbName.Text;
                followingEvent.IsActive       = cbIsActive.Checked;
                followingEvent.Description    = tbDescription.Text;
                followingEvent.EntityTypeId   = cpEventType.SelectedEntityTypeId;
                followingEvent.SendOnWeekends = !cbSendOnFriday.Checked;

                var eventEntityTypeGuid = EntityTypeCache.Get(cpEventType.SelectedEntityTypeId.Value).Guid.ToString();
                if (string.Equals(eventEntityTypeGuid, Rock.SystemGuid.EntityType.PERSON_PRAYER_REQUEST, StringComparison.OrdinalIgnoreCase))
                {
                    followingEvent.IncludeNonPublicRequests = cbIncludeNonPublicRequests.Checked;
                }

                followingEvent.IsNoticeRequired             = cbRequireNotification.Checked;
                followingEvent.EntityNotificationFormatLava = ceNotificationFormat.Text;

                followingEvent.FollowedEntityTypeId = null;
                var eventComponent = followingEvent.GetEventComponent();
                if (eventComponent != null)
                {
                    var followedEntityType = EntityTypeCache.Get(eventComponent.FollowedType);
                    if (followedEntityType != null)
                    {
                        followingEvent.FollowedEntityTypeId = followedEntityType.Id;
                    }
                }

                rockContext.SaveChanges();

                followingEvent.LoadAttributes(rockContext);
                Rock.Attribute.Helper.GetEditValues(phAttributes, followingEvent);
                followingEvent.SaveAttributeValues(rockContext);
            }

            NavigateToParentPage();
        }
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)
        {
            using (var rockContext = new RockContext())
            {
                FollowingEventType followingEvent = null;

                var eventService = new Rock.Model.FollowingEventTypeService(rockContext);

                if (EventId != 0)
                {
                    followingEvent = eventService.Get(EventId);
                }

                if (followingEvent == null)
                {
                    followingEvent = new Rock.Model.FollowingEventType();
                    eventService.Add(followingEvent);
                }

                followingEvent.Name                         = tbName.Text;
                followingEvent.IsActive                     = cbIsActive.Checked;
                followingEvent.Description                  = tbDescription.Text;
                followingEvent.EntityTypeId                 = cpEventType.SelectedEntityTypeId;
                followingEvent.SendOnWeekends               = !cbSendOnFriday.Checked;
                followingEvent.IsNoticeRequired             = cbRequireNotification.Checked;
                followingEvent.EntityNotificationFormatLava = ceNotificationFormat.Text;

                followingEvent.FollowedEntityTypeId = null;
                var eventComponent = followingEvent.GetEventComponent();
                if (eventComponent != null)
                {
                    var followedEntityType = EntityTypeCache.Get(eventComponent.FollowedType);
                    if (followedEntityType != null)
                    {
                        followingEvent.FollowedEntityTypeId = followedEntityType.Id;
                    }
                }

                rockContext.SaveChanges();

                followingEvent.LoadAttributes(rockContext);
                Rock.Attribute.Helper.GetEditValues(phAttributes, followingEvent);
                followingEvent.SaveAttributeValues(rockContext);
            }

            NavigateToParentPage();
        }
Exemple #3
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 )
        {
            using ( var rockContext = new RockContext() )
            {
                FollowingEventType followingEvent = null;

                var eventService = new Rock.Model.FollowingEventTypeService( rockContext );

                if ( EventId != 0 )
                {
                    followingEvent = eventService.Get( EventId );
                }

                if ( followingEvent == null )
                {
                    followingEvent = new Rock.Model.FollowingEventType();
                    eventService.Add( followingEvent );
                }

                followingEvent.Name = tbName.Text;
                followingEvent.IsActive = cbIsActive.Checked;
                followingEvent.Description = tbDescription.Text;
                followingEvent.EntityTypeId = cpEventType.SelectedEntityTypeId;
                followingEvent.SendOnWeekends = !cbSendOnFriday.Checked;
                followingEvent.IsNoticeRequired = cbRequireNotification.Checked;
                followingEvent.EntityNotificationFormatLava = ceNotificationFormat.Text;

                followingEvent.FollowedEntityTypeId = null;
                var eventComponent = followingEvent.GetEventComponent();
                if ( eventComponent != null )
                {
                    var followedEntityType = EntityTypeCache.Read( eventComponent.FollowedType );
                    if ( followedEntityType != null )
                    {
                        followingEvent.FollowedEntityTypeId = followedEntityType.Id;
                    }
                }

                rockContext.SaveChanges();

                followingEvent.LoadAttributes( rockContext );
                Rock.Attribute.Helper.GetEditValues( phAttributes, followingEvent );
                followingEvent.SaveAttributeValues( rockContext );
            }

            NavigateToParentPage();
        }