Пример #1
0
        /// <summary>
        /// Handles the Delete event of the gWorkflowTrigger 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 gWorkflowTrigger_Delete(object sender, RowEventArgs e)
        {
            var rockContext = new RockContext();
            WorkflowTriggerService WorkflowTriggerService = new WorkflowTriggerService(rockContext);
            WorkflowTrigger        WorkflowTrigger        = WorkflowTriggerService.Get(e.RowKeyId);

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

                WorkflowTriggerService.Delete(WorkflowTrigger);
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Пример #2
0
        /// <summary>
        /// Handles the Delete event of the gWorkflowTrigger 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 gWorkflowTrigger_Delete(object sender, RowEventArgs e)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                WorkflowTriggerService WorkflowTriggerService = new WorkflowTriggerService();
                WorkflowTrigger WorkflowTrigger = WorkflowTriggerService.Get((int)e.RowKeyValue);

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

                    WorkflowTriggerService.Delete(WorkflowTrigger, CurrentPersonId);
                    WorkflowTriggerService.Save(WorkflowTrigger, CurrentPersonId);
                }
            });

            BindGrid();
        }