예제 #1
0
        /// <summary>
        /// Handles the Delete event of the gSignatureDocumentTemplate 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 gSignatureDocumentTemplate_Delete(object sender, RowEventArgs e)
        {
            var rockContext = new RockContext();
            var signatureDocumentService         = new SignatureDocumentService(rockContext);
            var signatureDocumentTemplateService = new SignatureDocumentTemplateService(rockContext);

            SignatureDocumentTemplate type = signatureDocumentTemplateService.Get(e.RowKeyId);

            if (type != null)
            {
                if (!UserCanEdit && !type.IsAuthorized(Authorization.EDIT, CurrentPerson))
                {
                    mdGridWarning.Show("Sorry, you're not authorized to delete this signature document template.", ModalAlertType.Alert);
                    return;
                }

                string errorMessage;
                if (!signatureDocumentTemplateService.CanDelete(type, out errorMessage))
                {
                    mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                signatureDocumentTemplateService.Delete(type);

                rockContext.SaveChanges();
            }

            BindGrid();
        }
예제 #2
0
        /// <summary>
        /// Handles the Click event of the btnDelete 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 btnDelete_Click(object sender, EventArgs e)
        {
            RockContext rockContext = new RockContext();
            SignatureDocumentTemplateService signatureDocumentTemplateService = new SignatureDocumentTemplateService(rockContext);
            SignatureDocumentTemplate        signatureDocumentTemplate        = signatureDocumentTemplateService.Get(int.Parse(hfSignatureDocumentTemplateId.Value));

            if (signatureDocumentTemplate != null)
            {
                if (!signatureDocumentTemplate.IsAuthorized(Authorization.EDIT, this.CurrentPerson))
                {
                    mdDeleteWarning.Show("Sorry, You are not authorized to delete this document template.", ModalAlertType.Information);
                    return;
                }

                string errorMessage;
                if (!signatureDocumentTemplateService.CanDelete(signatureDocumentTemplate, out errorMessage))
                {
                    mdDeleteWarning.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                signatureDocumentTemplateService.Delete(signatureDocumentTemplate);

                rockContext.SaveChanges();
            }

            NavigateToParentPage();
        }