예제 #1
0
        /// <summary>
        /// Handles the ItemCommand event of the rptrBlocks control.
        /// </summary>
        /// <param name="source">The source of the event.</param>
        /// <param name="e">The <see cref="RepeaterCommandEventArgs"/> instance containing the event data.</param>
        protected void rptrBlocks_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                var rockContext  = new RockContext();
                var blockService = new BlockService(rockContext);

                var block = blockService.Get(e.CommandArgument.ToString().AsInteger());
                blockService.Delete(block);
                rockContext.SaveChanges();

                BindZones();
            }
        }
예제 #2
0
        /// <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 (CurrentBlock != null)
            {
                blockService.Delete(block, CurrentPersonId);
                blockService.Save(block, CurrentPersonId);
                Rock.Web.Cache.PageCache.FlushLayoutBlocks(page.Layout);
            }

            BindGrids();
        }
예제 #3
0
        /// <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();
        }
예제 #4
0
        /// <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 (CurrentBlock != null)
            {
                blockService.Delete(block, CurrentPersonId);
                blockService.Save(block, CurrentPersonId);
                page.FlushBlocks();
            }

            BindGrids();
        }
예제 #5
0
        /// <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() ?? 0;

            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();
        }
예제 #6
0
        /// <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() ?? 0;

            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();
        }
예제 #7
0
        /// <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();
            }

            BindLayoutBlocksGrid();
        }
예제 #8
0
        /// <summary>
        /// Handles the Click event of the btnDeleteBlock control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnDeleteBlock_Click(object sender, EventArgs e)
        {
            LinkButton btnDelete = sender as LinkButton;
            int?       blockId   = btnDelete.CommandArgument.AsIntegerOrNull();

            if (blockId.HasValue)
            {
                var rockContext  = new RockContext();
                var blockService = new BlockService(rockContext);
                var block        = blockService.Get(blockId.Value);

                if (block != null)
                {
                    int?pageId   = block.PageId;
                    int?layoutId = block.LayoutId;
                    blockService.Delete(block);
                    rockContext.SaveChanges();

                    ShowDetailForZone(ddlZones.SelectedValue);
                }
            }
        }
예제 #9
0
        /// <summary>
        /// Handles the Click event of the btnDeleteBlock control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnDeleteBlock_Click(object sender, EventArgs e)
        {
            LinkButton btnDelete = sender as LinkButton;
            int?       blockId   = btnDelete.CommandArgument.AsIntegerOrNull();

            if (blockId.HasValue)
            {
                var rockContext  = new RockContext();
                var blockService = new BlockService(rockContext);
                var block        = blockService.Get(blockId.Value);

                if (block != null)
                {
                    int?pageId   = block.PageId;
                    int?layoutId = block.LayoutId;
                    blockService.Delete(block);
                    rockContext.SaveChanges();

                    // flush all the cache stuff that involves the block
                    Rock.Web.Cache.BlockCache.Flush(blockId.Value);

                    if (layoutId.HasValue)
                    {
                        Rock.Web.Cache.PageCache.FlushLayoutBlocks(layoutId.Value);
                    }

                    if (pageId.HasValue)
                    {
                        Rock.Web.Cache.PageCache.Flush(pageId.Value);
                        var page = Rock.Web.Cache.PageCache.Read(pageId.Value);
                        page.FlushBlocks();
                    }

                    ShowDetailForZone(ddlZones.SelectedValue);
                }
            }
        }
예제 #10
0
 public ActionResult delblock(string id)
 {
     BlockService.Delete(id);
     return(new StringResult(null));
 }