protected void TagItemCommand(object o, GridCommandEventArgs e)
        {
            if (e.CommandName == RadGrid.InitInsertCommandName)
            {
                e.Canceled = true;
                var i = new CampaignTag();
                i.Tag      = "";
                i.ID       = 0;
                i.IsPublic = false;
                e.Item.OwnerTableView.InsertItem(i);
            }

            if (e.CommandName == RadGrid.PerformInsertCommandName)
            {
                var tag = new CampaignTag();
                tag.Tag      = (e.Item.FindControl("tbTag") as IdeaSeed.Web.UI.TextBox).Text;
                tag.IsPublic = (e.Item.FindControl("cbIsPublic") as IdeaSeed.Web.UI.CheckBox).Checked;
                new CMData.CampaignTagRepository().Save(tag);
            }
            if (e.CommandName == RadGrid.UpdateCommandName)
            {
                var tag = new CMData.CampaignTagRepository().GetByID((int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"], false);
                tag.Tag      = (e.Item.FindControl("tbTag") as IdeaSeed.Web.UI.TextBox).Text;
                tag.IsPublic = (e.Item.FindControl("cbIsPublic") as IdeaSeed.Web.UI.CheckBox).Checked;
                new CMData.CampaignTagRepository().SaveOrUpdate(tag);
            }
            if (e.CommandName == RadGrid.DeleteCommandName)
            {
                var tag = new CMData.CampaignTagRepository().GetByID((int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"], false);
                try
                {
                    new CMData.CampaignTagRepository().Delete(tag);
                }
                catch (Exception ex)
                {
                    ShowErrorModal(this, "This tag is associated with one or more subscribers, or campaigns and cannot be deleted.  You must first remove this tag from all subscribers and campaigns.");
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Update a campaign tag
 /// </summary>
 /// <param name="accountID">Your Account ID, used for authorization (Found in the EmailCampaigns app in the "API credentials" page in Settings)</param>
 /// <param name="campaignTagID">The ID of the campaign tag that you want to update</param>
 /// <param name="campaignTag">This is the updated campaign tag</param>
 /// <param name="cancellationToken">An optional cancellation token to abort this request</param>
 /// <returns></returns>
 public async Task <CampaignTag> UpdateCampaignTagAsync(Guid accountID, Guid campaignTagID, CampaignTag campaignTag, CancellationToken cancellationToken = default)
 {
     return(await PutAsync <CampaignTag>($"/bulkemail/v1.0/accounts/{accountID}/campaigntags/{campaignTagID}", campaignTag, cancellationToken).ConfigureAwait(false));
 }
        /*replaced by checking null!
         * private bool LocationExists(int id)
         * {
         *  return db.Locations.Count(e => e.Id == id) > 0;
         * }*/

        private bool TagExist(CampaignTag campaignTag)
        {
            return(db.CampaignTags.Count(t => t.Name == campaignTag.Name) > 0);
        }