/// <summary>
        /// Handles the Delete event of the gWorkflowTypeAttributes 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 gWorkflowTypeAttributes_Delete(object sender, RowEventArgs e)
        {
            Guid             attributeGuid    = (Guid)e.RowKeyValue;
            AttributeService attributeService = new AttributeService();
            Attribute        attribute        = attributeService.Get(attributeGuid);

            if (attribute != null)
            {
                string errorMessage;
                if (!attributeService.CanDelete(attribute, out errorMessage))
                {
                    mdGridWarningAttributes.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                Rock.Web.Cache.AttributeCache.Flush(attribute.Id);
                attributeService.Delete(attribute, CurrentPersonId);
                attributeService.Save(attribute, CurrentPersonId);
            }

            // reload page so that other blocks respond to any data that was changed
            var qryParams = new Dictionary <string, string>();

            qryParams["workflowTypeId"] = hfWorkflowTypeId.Value;
            NavigateToPage(RockPage.Guid, qryParams);
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the Delete event of the gDefinedTypeAttributes 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 gDefinedTypeAttributes_Delete(object sender, RowEventArgs e)
        {
            Guid             attributeGuid    = (Guid)e.RowKeyValue;
            var              rockContext      = new RockContext();
            AttributeService attributeService = new AttributeService(rockContext);
            Attribute        attribute        = attributeService.Get(attributeGuid);

            if (attribute != null)
            {
                string errorMessage;
                if (!attributeService.CanDelete(attribute, out errorMessage))
                {
                    mdGridWarningAttributes.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                AttributeCache.Flush(attribute.Id);
                attributeService.Delete(attribute);
                rockContext.SaveChanges();
            }

            AttributeCache.FlushEntityAttributes();

            BindDefinedTypeAttributesGrid();
        }
        /// <summary>
        /// Handles the Delete event of the gDefinedTypeAttributes 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 gDefinedTypeAttributes_Delete(object sender, RowEventArgs e)
        {
            Guid             attributeGuid    = (Guid)e.RowKeyValue;
            AttributeService attributeService = new AttributeService();
            Attribute        attribute        = attributeService.Get(attributeGuid);

            if (attribute != null)
            {
                string errorMessage;
                if (!attributeService.CanDelete(attribute, out errorMessage))
                {
                    mdGridWarningAttributes.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                AttributeCache.Flush(attribute.Id);
                attributeService.Delete(attribute, CurrentPersonId);
                attributeService.Save(attribute, CurrentPersonId);
            }

            BindDefinedTypeAttributesGrid();
        }
Esempio n. 4
0
        /// <summary>
        /// Handles the DeleteClick event of the gBlockTypeAttributes control.
        /// </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 gBlockTypeAttributes_DeleteClick(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            Guid             attributeGuid    = (Guid)e.RowKeyValue;
            var              rockContext      = new RockContext();
            AttributeService attributeService = new AttributeService(rockContext);
            Attribute        attribute        = attributeService.Get(attributeGuid);

            if (attribute != null)
            {
                string errorMessage;
                if (!attributeService.CanDelete(attribute, out errorMessage))
                {
                    mdGridWarningAttributes.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                attributeService.Delete(attribute);
                rockContext.SaveChanges();
            }

            BindBlockTypeAttributesGrid();
        }