protected void gLayoutBlocks_Delete(object sender, RowEventArgs e) { Rock.Model.Block block = blockService.Get(( int )gLayoutBlocks.DataKeys[e.RowIndex]["id"]); if (CurrentBlock != null) { blockService.Delete(block, CurrentPersonId); blockService.Save(block, CurrentPersonId); Rock.Web.Cache.PageCache.FlushLayoutBlocks(_page.Layout); } BindGrids(); }
/// <summary> /// Deletes the specified item. Will try to determine current person /// alias from HttpContext. /// </summary> /// <param name="item">The item.</param> /// <returns></returns> public override bool Delete(BlockType item) { // block has a cascading delete on BlockType, but lets delete it manually so that the BlockCache gets updated correctly var blockService = new BlockService(this.Context as RockContext); var blocks = blockService.Queryable().Where(a => a.BlockTypeId == item.Id).ToList(); foreach (var block in blocks) { blockService.Delete(block); } return(base.Delete(item)); }
/// <summary> /// Handles the Delete event of the gPageBlocks 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 gPageBlocks_Delete( object sender, RowEventArgs e ) { using ( var rockContext = new RockContext() ) { BlockService blockService = new BlockService( rockContext ); Rock.Model.Block block = blockService.Get( e.RowKeyId ); if ( block != null ) { blockService.Delete( block ); rockContext.SaveChanges(); _Page.FlushBlocks(); PageUpdated = true; } } BindGrids(); }
/// <summary> /// Handles the Delete click event for the grid. /// </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 DeleteBlock_Click( object sender, Rock.Web.UI.Controls.RowEventArgs e ) { var rockContext = new RockContext(); BlockService blockService = new BlockService( rockContext ); Block block = blockService.Get( e.RowKeyId ); if ( block != null ) { string errorMessage; if ( !blockService.CanDelete( block, out errorMessage ) ) { mdGridWarning.Show( errorMessage, ModalAlertType.Information ); return; } blockService.Delete( block ); rockContext.SaveChanges(); BlockCache.Flush( e.RowKeyId ); } BindLayoutBlocksGrid(); }
/// <summary> /// Handles the Delete event of the gPageBlocks 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 gPageBlocks_Delete( object sender, RowEventArgs e ) { int pageId = PageParameter( "EditPage" ).AsInteger(); Rock.Web.Cache.PageCache page = Rock.Web.Cache.PageCache.Read( pageId ); string zoneName = this.PageParameter( "ZoneName" ); var rockContext = new RockContext(); BlockService blockService = new BlockService( rockContext ); Rock.Model.Block block = blockService.Get( e.RowKeyId ); if ( block != null ) { blockService.Delete( block ); rockContext.SaveChanges(); page.FlushBlocks(); } BindGrids(); }
/// <summary> /// Handles the Delete event of the gLayoutBlocks 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 gLayoutBlocks_Delete( object sender, RowEventArgs e ) { int pageId = PageParameter( "EditPage" ).AsInteger(); Rock.Web.Cache.PageCache page = Rock.Web.Cache.PageCache.Read( pageId ); var rockContext = new RockContext(); BlockService blockService = new BlockService( rockContext ); Rock.Model.Block block = blockService.Get( (int)gLayoutBlocks.DataKeys[e.RowIndex]["id"] ); if ( block != null ) { blockService.Delete( block ); rockContext.SaveChanges(); Rock.Web.Cache.PageCache.FlushLayoutBlocks( page.LayoutId ); } BindGrids(); }
/// <summary> /// Handles the Delete event of the gPageBlocks 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 gPageBlocks_Delete( object sender, RowEventArgs e ) { BlockService blockService = new BlockService(); int pageId = PageParameter( "EditPage" ).AsInteger() ?? 0; Rock.Web.Cache.PageCache page = Rock.Web.Cache.PageCache.Read( pageId ); string zoneName = this.PageParameter( "ZoneName" ); Rock.Model.Block block = blockService.Get( e.RowKeyId ); if ( block != null ) { blockService.Delete( block, CurrentPersonId ); blockService.Save( block, CurrentPersonId ); page.FlushBlocks(); } BindGrids(); }
/// <summary> /// Handles the Delete event of the gLayoutBlocks 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 gLayoutBlocks_Delete( object sender, RowEventArgs e ) { BlockService blockService = new BlockService(); int pageId = PageParameter( "EditPage" ).AsInteger() ?? 0; Rock.Web.Cache.PageCache page = Rock.Web.Cache.PageCache.Read( pageId ); Rock.Model.Block block = blockService.Get( (int)gLayoutBlocks.DataKeys[e.RowIndex]["id"] ); if ( block != null ) { blockService.Delete( block, CurrentPersonId ); blockService.Save( block, CurrentPersonId ); Rock.Web.Cache.PageCache.FlushLayoutBlocks( page.LayoutId ); } BindGrids(); }