示例#1
0
        /// <summary>
        /// Handles the Delete event of the gBlockTypes 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 gBlockTypes_Delete(object sender, RowEventArgs e)
        {
            BlockTypeService blockTypeService = new BlockTypeService();
            BlockType        blockType        = blockTypeService.Get((int)gBlockTypes.DataKeys[e.RowIndex]["id"]);

            if (CurrentBlock != null)
            {
                blockTypeService.Delete(blockType, CurrentPersonId);
                blockTypeService.Save(blockType, CurrentPersonId);

                Rock.Web.Cache.BlockTypeCache.Flush(blockType.Id);
            }

            BindGrid();
        }
示例#2
0
        /// <summary>
        /// Handles the Delete event of the gBlockTypes 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 gBlockTypes_Delete(object sender, RowEventArgs e)
        {
            var rockContext = new RockContext();
            BlockTypeService blockTypeService = new BlockTypeService(rockContext);
            BlockType        blockType        = blockTypeService.Get(e.RowKeyId);

            if (blockType != null)
            {
                string errorMessage;
                if (!blockTypeService.CanDelete(blockType, out errorMessage))
                {
                    mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                blockTypeService.Delete(blockType);
                rockContext.SaveChanges();
            }

            BindGrid();
        }
示例#3
0
        /// <summary>
        /// Handles the Delete event of the gBlockTypes 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 gBlockTypes_Delete(object sender, RowEventArgs e)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                BlockTypeService blockTypeService = new BlockTypeService();
                BlockType blockType = blockTypeService.Get((int)e.RowKeyValue);
                if (blockType != null)
                {
                    string errorMessage;
                    if (!blockTypeService.CanDelete(blockType, out errorMessage))
                    {
                        mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    blockTypeService.Delete(blockType, CurrentPersonId);
                    blockTypeService.Save(blockType, CurrentPersonId);
                    Rock.Web.Cache.BlockTypeCache.Flush(blockType.Id);
                }
            });

            BindGrid();
        }