コード例 #1
0
        /// <summary>
        /// Handles the DeleteClick event of the gAccountList 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 gAccountList_DeleteClick(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var rockContext         = new RockContext();
            var mediaAccountService = new MediaAccountService(rockContext);
            var mediaAccount        = mediaAccountService.Get(e.RowKeyId);

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

                mediaAccountService.Delete(mediaAccount);
                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)
        {
            var rockContext = new RockContext();

            var service      = new MediaAccountService(rockContext);
            var mediaAccount = service.Get(int.Parse(hfMediaAccountId.Value));

            if (mediaAccount == null)
            {
                return;
            }

            service.Delete(mediaAccount);

            rockContext.SaveChanges();

            // reload page
            var qryParams = new Dictionary <string, string>();

            NavigateToParentPage(qryParams);
        }