Exemplo n.º 1
0
        /// <summary>
        /// Handles the Delete event of the gBadge 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 gBadge_Delete(object sender, RowEventArgs e)
        {
            var rockContext  = new RockContext();
            var badgeService = new BadgeService(rockContext);
            var badge        = badgeService.Get(e.RowKeyId);

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

                badgeService.Delete(badge);
                rockContext.SaveChanges();
            }

            BindGrid();
        }