Ejemplo n.º 1
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            BlockType        blockType;
            var              rockContext      = new RockContext();
            BlockTypeService blockTypeService = new BlockTypeService(rockContext);

            int blockTypeId = int.Parse(hfBlockTypeId.Value);

            if (blockTypeId == 0)
            {
                blockType = new BlockType();
                blockTypeService.Add(blockType);
            }
            else
            {
                BlockTypeCache.Flush(blockTypeId);
                blockType = blockTypeService.Get(blockTypeId);
            }

            blockType.Name        = tbName.Text;
            blockType.Path        = tbPath.Text;
            blockType.Description = tbDescription.Text;

            if (!blockType.IsValid)
            {
                // Controls will render the error messages
                return;
            }

            rockContext.SaveChanges();

            NavigateToParentPage();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            BlockType        blockType;
            BlockTypeService blockTypeService = new BlockTypeService();

            int blockTypeId = int.Parse(hfBlockTypeId.Value);

            if (blockTypeId == 0)
            {
                blockType = new BlockType();
                blockTypeService.Add(blockType, CurrentPersonId);
            }
            else
            {
                BlockTypeCache.Flush(blockTypeId);
                blockType = blockTypeService.Get(blockTypeId);
            }

            blockType.Name        = tbName.Text;
            blockType.Path        = tbPath.Text;
            blockType.Description = tbDescription.Text;

            if (!blockType.IsValid)
            {
                // Controls will render the error messages
                return;
            }

            blockTypeService.Save(blockType, CurrentPersonId);

            BindGrid();

            pnlDetails.Visible = false;
            pnlList.Visible    = true;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            BlockType        blockType;
            BlockTypeService blockTypeService = new BlockTypeService();

            int blockTypeId = int.Parse(hfBlockTypeId.Value);

            if (blockTypeId == 0)
            {
                blockType = new BlockType();
                blockTypeService.Add(blockType, CurrentPersonId);
            }
            else
            {
                BlockTypeCache.Flush(blockTypeId);
                blockType = blockTypeService.Get(blockTypeId);
            }

            blockType.Name        = tbName.Text;
            blockType.Path        = tbPath.Text;
            blockType.Description = tbDescription.Text;

            if (!blockType.IsValid)
            {
                // Controls will render the error messages
                return;
            }

            RockTransactionScope.WrapTransaction(() =>
            {
                blockTypeService.Save(blockType, CurrentPersonId);
            });

            NavigateToParentPage();
        }
        /// <summary>
        /// Flushes the block type attributes.
        /// </summary>
        private void FlushBlockTypeAttributes()
        {
            // Flush BlockType, Block and Entity Attributes
            AttributeCache.FlushEntityAttributes();

            BlockTypeCache.Flush(hfBlockTypeId.Value.AsInteger());
            var blockTypeCache = BlockTypeCache.Read(hfBlockTypeId.Value.AsInteger());

            foreach (var blockId in new BlockService(new RockContext()).GetByBlockTypeId(hfBlockTypeId.Value.AsInteger()).Select(a => a.Id).ToList())
            {
                BlockCache.Flush(blockId);
            }
        }