/// <summary>
        /// Handles the Delete event of the gMarketingCampaigns 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 gMarketingCampaigns_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            MarketingCampaignService marketingCampaignService = new MarketingCampaignService( rockContext );

            MarketingCampaign marketingCampaign = marketingCampaignService.Get( (int)e.RowKeyValue );

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

                marketingCampaignService.Delete( marketingCampaign );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Пример #2
0
        /// <summary>
        /// Handles the Delete event of the gMarketingCampaigns 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 gMarketingCampaigns_Delete(object sender, RowEventArgs e)
        {
            var rockContext = new RockContext();
            MarketingCampaignService marketingCampaignService = new MarketingCampaignService(rockContext);

            MarketingCampaign marketingCampaign = marketingCampaignService.Get((int)e.RowKeyValue);

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

                marketingCampaignService.Delete(marketingCampaign);
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Пример #3
0
        /// <summary>
        /// Handles the Delete event of the gMarketingCampaigns 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 gMarketingCampaigns_Delete(object sender, RowEventArgs e)
        {
            MarketingCampaignService marketingCampaignService = new MarketingCampaignService();
            int marketingCampaignId             = (int)e.RowKeyValue;
            MarketingCampaign marketingCampaign = marketingCampaignService.Get(marketingCampaignId);

            string errorMessage;

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

            if (CurrentBlock != null)
            {
                marketingCampaignService.Delete(marketingCampaign, CurrentPersonId);
                marketingCampaignService.Save(marketingCampaign, CurrentPersonId);
            }

            BindGrid();
        }
Пример #4
0
        /// <summary>
        /// Handles the Delete event of the gMarketingCampaigns 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 gMarketingCampaigns_Delete(object sender, RowEventArgs e)
        {
            RockTransactionScope.WrapTransaction(() =>
            {
                MarketingCampaignService marketingCampaignService = new MarketingCampaignService();
                MarketingCampaign marketingCampaign = marketingCampaignService.Get((int)e.RowKeyValue);

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

                    marketingCampaignService.Delete(marketingCampaign, CurrentPersonId);
                    marketingCampaignService.Save(marketingCampaign, CurrentPersonId);
                }
            });

            BindGrid();
        }
Пример #5
0
        /// <summary>
        /// Handles the Delete event of the gMarketingCampaigns 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 gMarketingCampaigns_Delete( object sender, RowEventArgs e )
        {
            RockTransactionScope.WrapTransaction( () =>
            {
                MarketingCampaignService marketingCampaignService = new MarketingCampaignService();
                MarketingCampaign marketingCampaign = marketingCampaignService.Get( (int)e.RowKeyValue );

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

                    marketingCampaignService.Delete( marketingCampaign, CurrentPersonId );
                    marketingCampaignService.Save( marketingCampaign, CurrentPersonId );
                }
            } );

            BindGrid();
        }
Пример #6
0
        /// <summary>
        /// Handles the Delete event of the gMarketingCampaigns 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 gMarketingCampaigns_Delete( object sender, RowEventArgs e )
        {
            MarketingCampaignService marketingCampaignService = new MarketingCampaignService();
            int marketingCampaignId = (int)e.RowKeyValue;
            MarketingCampaign marketingCampaign = marketingCampaignService.Get( marketingCampaignId );

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

            if ( CurrentBlock != null )
            {
                marketingCampaignService.Delete( marketingCampaign, CurrentPersonId );
                marketingCampaignService.Save( marketingCampaign, CurrentPersonId );
            }

            BindGrid();
        }