/// <summary> /// Handles the Delete event of the gCommunicationTemplates control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param> protected void gCommunicationTemplates_Delete(object sender, RowEventArgs e) { var rockContext = new RockContext(); var service = new CommunicationTemplateService(rockContext); var template = service.Get(e.RowKeyId); if (template != null) { if (!template.IsAuthorized(Authorization.EDIT, CurrentPerson)) { maGridWarning.Show("You are not authorized to delete this template", ModalAlertType.Information); return; } string errorMessage; if (!service.CanDelete(template, out errorMessage)) { maGridWarning.Show(errorMessage, ModalAlertType.Information); return; } service.Delete(template); rockContext.SaveChanges(); } BindGrid(); }
/// <summary> /// Handles the Delete event of the gCommunication control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param> protected void gCommunication_Delete( object sender, Rock.Web.UI.Controls.RowEventArgs e ) { var rockContext = new RockContext(); var service = new CommunicationTemplateService( rockContext ); var template = service.Get( e.RowKeyId ); if ( template != null ) { if ( !template.IsAuthorized( Authorization.EDIT, this.CurrentPerson ) ) { maGridWarning.Show( "You are not authorized to delete this template", ModalAlertType.Information ); return; } string errorMessage; if ( !service.CanDelete( template, out errorMessage ) ) { maGridWarning.Show( errorMessage, ModalAlertType.Information ); return; } service.Delete( template ); rockContext.SaveChanges(); } BindGrid(); }