/// <summary>
        /// Handles the Delete event of the gCalendarItemOccurrenceList 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 gCalendarItemOccurrenceList_Delete(object sender, RowEventArgs e)
        {
            using (RockContext rockContext = new RockContext())
            {
                EventItemOccurrenceService eventItemOccurrenceService = new EventItemOccurrenceService(rockContext);
                EventItemOccurrence        eventItemOccurrence        = eventItemOccurrenceService.Get(e.RowKeyId);
                if (eventItemOccurrence != null)
                {
                    string errorMessage;
                    if (!eventItemOccurrenceService.CanDelete(eventItemOccurrence, out errorMessage))
                    {
                        mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    eventItemOccurrenceService.Delete(eventItemOccurrence);
                    rockContext.SaveChanges();
                }
            }

            BindCampusGrid();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the Click event of the btnDelete 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 btnDelete_Click(object sender, EventArgs e)
        {
            using (var rockContext = new RockContext())
            {
                EventItemOccurrenceService eventItemOccurrenceService = new EventItemOccurrenceService(rockContext);
                EventItemOccurrence        eventItemOccurrence        = eventItemOccurrenceService.Get(hfEventItemOccurrenceId.Value.AsInteger());

                if (eventItemOccurrence != null)
                {
                    string errorMessage;
                    if (!eventItemOccurrenceService.CanDelete(eventItemOccurrence, out errorMessage))
                    {
                        mdDeleteWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    eventItemOccurrenceService.Delete(eventItemOccurrence);

                    rockContext.SaveChanges();
                }
            }

            NavigateToParentPage();
        }
        /// <summary>
        /// Handles the Click event of the btnDelete 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 btnDelete_Click( object sender, EventArgs e )
        {
            using ( var rockContext = new RockContext() )
            {
                EventItemOccurrenceService eventItemOccurrenceService = new EventItemOccurrenceService( rockContext );
                EventItemOccurrence eventItemOccurrence = eventItemOccurrenceService.Get( hfEventItemOccurrenceId.Value.AsInteger() );

                if ( eventItemOccurrence != null )
                {
                    string errorMessage;
                    if ( !eventItemOccurrenceService.CanDelete( eventItemOccurrence, out errorMessage ) )
                    {
                        mdDeleteWarning.Show( errorMessage, ModalAlertType.Information );
                        return;
                    }

                    eventItemOccurrenceService.Delete( eventItemOccurrence );

                    rockContext.SaveChanges();
                }
            }

            NavigateToParentPage();
        }
        /// <summary>
        /// Handles the Delete event of the gCalendarItemOccurrenceList 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 gCalendarItemOccurrenceList_Delete( object sender, RowEventArgs e )
        {
            using ( RockContext rockContext = new RockContext() )
            {
                EventItemOccurrenceService eventItemOccurrenceService = new EventItemOccurrenceService( rockContext );
                EventItemOccurrence eventItemOccurrence = eventItemOccurrenceService.Get( e.RowKeyId );
                if ( eventItemOccurrence != null )
                {
                    string errorMessage;
                    if ( !eventItemOccurrenceService.CanDelete( eventItemOccurrence, out errorMessage ) )
                    {
                        mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                        return;
                    }

                    eventItemOccurrenceService.Delete( eventItemOccurrence );
                    rockContext.SaveChanges();
                }
            }

            BindCampusGrid();
        }