예제 #1
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)
        {
            if (_channel != null)
            {
                if (!_channel.IsAuthorized(Authorization.EDIT, this.CurrentPerson))
                {
                    mdDeleteWarning.Show("You are not authorized to delete this interaction channel.", ModalAlertType.Information);
                    return;
                }

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

                _channelService.Delete(_channel);
                _rockContext.SaveChanges();

                NavigateToParentPage();
            }
        }