/// <summary> /// Handles the Delete event of the grdScheduledJobs 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 gScheduledJobs_Delete( object sender, RowEventArgs e ) { var rockContext = new RockContext(); var jobService = new ServiceJobService( rockContext ); ServiceJob job = jobService.Get( e.RowKeyId ); string errorMessage; if ( !jobService.CanDelete( job, out errorMessage ) ) { mdGridWarning.Show( errorMessage, ModalAlertType.Information ); return; } jobService.Delete( job ); rockContext.SaveChanges(); BindGrid(); }
/// <summary> /// Handles the Delete event of the grdScheduledJobs 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 gScheduledJobs_Delete( object sender, RowEventArgs e ) { RockTransactionScope.WrapTransaction( () => { var jobService = new ServiceJobService(); ServiceJob job = jobService.Get( (int)e.RowKeyValue ); string errorMessage; if ( !jobService.CanDelete( job, out errorMessage ) ) { mdGridWarning.Show( errorMessage, ModalAlertType.Information ); return; } jobService.Delete( job, CurrentPersonId ); jobService.Save( job, CurrentPersonId ); } ); BindGrid(); }