/// <summary>
        /// Handles the Delete event of the gMarketingCampaignAdType 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 gMarketingCampaignAdType_Delete(object sender, RowEventArgs e)
        {
            MarketingCampaignAdTypeService marketingCampaignAdTypeService = new MarketingCampaignAdTypeService();
            int marketingCampaignAdTypeId = (int)e.RowKeyValue;
            MarketingCampaignAdType marketingCampaignAdType = marketingCampaignAdTypeService.Get(marketingCampaignAdTypeId);

            string errorMessage;

            if (!marketingCampaignAdTypeService.CanDelete(marketingCampaignAdType, out errorMessage))
            {
                mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                return;
            }

            if (CurrentBlock != null)
            {
                marketingCampaignAdTypeService.Delete(marketingCampaignAdType, CurrentPersonId);
                marketingCampaignAdTypeService.Save(marketingCampaignAdType, CurrentPersonId);
            }

            BindGrid();
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the Delete event of the gMarketingCampaignAdType 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 gMarketingCampaignAdType_Delete(object sender, RowEventArgs e)
        {
            var rockContext = new RockContext();
            MarketingCampaignAdTypeService marketingCampaignAdTypeService = new MarketingCampaignAdTypeService(rockContext);
            MarketingCampaignAdType        marketingCampaignAdType        = marketingCampaignAdTypeService.Get((int)e.RowKeyValue);

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

                marketingCampaignAdTypeService.Delete(marketingCampaignAdType);

                rockContext.SaveChanges();
            }

            BindGrid();
        }
Esempio n. 3
0
        /// <summary>
        /// Handles the Delete event of the gMarketingCampaignAdType 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 gMarketingCampaignAdType_Delete(object sender, RowEventArgs e)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                MarketingCampaignAdTypeService marketingCampaignAdTypeService = new MarketingCampaignAdTypeService();
                MarketingCampaignAdType marketingCampaignAdType = marketingCampaignAdTypeService.Get((int)e.RowKeyValue);

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

                    marketingCampaignAdTypeService.Delete(marketingCampaignAdType, CurrentPersonId);
                    marketingCampaignAdTypeService.Save(marketingCampaignAdType, CurrentPersonId);
                }
            });

            BindGrid();
        }