/// <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(); }
/// <summary> /// Clones this FollowingEventType object to a new FollowingEventType object /// </summary> /// <param name="source">The source.</param> /// <param name="deepCopy">if set to <c>true</c> a deep copy is made. If false, only the basic entity properties are copied.</param> /// <returns></returns> public static FollowingEventType Clone(this FollowingEventType source, bool deepCopy) { if (deepCopy) { return(source.Clone() as FollowingEventType); } else { var target = new FollowingEventType(); target.CopyPropertiesFrom(source); return(target); } }
/// <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(); }
/// <summary> /// Copies the properties from another FollowingEventType object to this FollowingEventType object /// </summary> /// <param name="target">The target.</param> /// <param name="source">The source.</param> public static void CopyPropertiesFrom(this FollowingEventType target, FollowingEventType source) { target.Id = source.Id; target.Description = source.Description; target.EntityNotificationFormatLava = source.EntityNotificationFormatLava; target.EntityTypeId = source.EntityTypeId; target.FollowedEntityTypeId = source.FollowedEntityTypeId; target.ForeignGuid = source.ForeignGuid; target.ForeignKey = source.ForeignKey; target.IsActive = source.IsActive; target.IsNoticeRequired = source.IsNoticeRequired; target.LastCheckDateTime = source.LastCheckDateTime; target.Name = source.Name; target.Order = source.Order; target.SendOnWeekends = source.SendOnWeekends; target.CreatedDateTime = source.CreatedDateTime; target.ModifiedDateTime = source.ModifiedDateTime; target.CreatedByPersonAliasId = source.CreatedByPersonAliasId; target.ModifiedByPersonAliasId = source.ModifiedByPersonAliasId; target.Guid = source.Guid; target.ForeignId = source.ForeignId; }
/// <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(); }