/// <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())
            {
                var service = new EventItemOccurrenceGroupMapService(rockContext);

                EventItemOccurrenceGroupMap linkage = null;

                int?linkageId = hfLinkageId.Value.AsIntegerOrNull();
                if (linkageId.HasValue)
                {
                    linkage = service.Get(linkageId.Value);
                }

                if (linkage == null)
                {
                    linkage = new EventItemOccurrenceGroupMap();
                    linkage.RegistrationInstanceId = PageParameter("RegistrationInstanceId").AsInteger();
                    service.Add(linkage);
                }

                linkage.EventItemOccurrenceId = hfLinkageEventItemOccurrenceId.Value.AsIntegerOrNull();
                linkage.GroupId    = gpLinkageGroup.SelectedValueAsInt();
                linkage.PublicName = tbLinkagePublicName.Text;
                linkage.UrlSlug    = tbLinkageUrlSlug.Text;

                if (!Page.IsValid || !linkage.IsValid)
                {
                    return;
                }

                rockContext.SaveChanges();
            }

            var qryParams = new Dictionary <string, string>();

            qryParams.Add("RegistrationInstanceId", PageParameter("RegistrationInstanceId"));
            qryParams.Add("Tab", "4");
            NavigateToParentPage(qryParams);
        }
        /// <summary>
        /// Handles the Delete event of the gLinkages control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
        protected void gLinkages_Delete(object sender, RowEventArgs e)
        {
            using (var rockContext = new RockContext())
            {
                var campusEventItemService = new EventItemOccurrenceGroupMapService(rockContext);
                var campusEventItem        = campusEventItemService.Get(e.RowKeyId);
                if (campusEventItem != null)
                {
                    string errorMessage;
                    if (!campusEventItemService.CanDelete(campusEventItem, out errorMessage))
                    {
                        mdLinkagesGridWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    campusEventItemService.Delete(campusEventItem);
                    rockContext.SaveChanges();
                }
            }

            BindLinkagesGrid();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the Delete event of the gLinkages control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
        protected void gLinkages_Delete( object sender, RowEventArgs e )
        {
            using ( var rockContext = new RockContext() )
            {
                var campusEventItemService = new EventItemOccurrenceGroupMapService( rockContext );
                var campusEventItem = campusEventItemService.Get( e.RowKeyId );
                if ( campusEventItem != null )
                {
                    string errorMessage;
                    if ( !campusEventItemService.CanDelete( campusEventItem, out errorMessage ) )
                    {
                        mdLinkagesGridWarning.Show( errorMessage, ModalAlertType.Information );
                        return;
                    }

                    campusEventItemService.Delete( campusEventItem );
                    rockContext.SaveChanges();
                }
            }

            BindLinkagesGrid();
        }
Ejemplo n.º 4
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() )
            {
                var service = new EventItemOccurrenceGroupMapService( rockContext );

                EventItemOccurrenceGroupMap linkage = null;

                int? linkageId = hfLinkageId.Value.AsIntegerOrNull();
                if ( linkageId.HasValue )
                {
                    linkage = service.Get( linkageId.Value );
                }

                if ( linkage == null )
                {
                    linkage = new EventItemOccurrenceGroupMap();
                    linkage.RegistrationInstanceId = PageParameter( "RegistrationInstanceId" ).AsInteger();
                    service.Add( linkage );
                }

                linkage.EventItemOccurrenceId = hfLinkageEventItemOccurrenceId.Value.AsIntegerOrNull();
                linkage.GroupId = gpLinkageGroup.SelectedValueAsInt();
                linkage.PublicName = tbLinkagePublicName.Text;
                linkage.UrlSlug = tbLinkageUrlSlug.Text;

                if ( !Page.IsValid || !linkage.IsValid )
                {
                    return;
                }

                rockContext.SaveChanges();
            }

            var qryParams = new Dictionary<string, string>();
            qryParams.Add( "RegistrationInstanceId", PageParameter( "RegistrationInstanceId" ) );
            qryParams.Add( "Tab", "3" );
            NavigateToParentPage( qryParams );
        }