コード例 #1
0
        public void Add(CmsCampaign campaign)
        {
            if (campaign.SubscriptionId == null)
                throw new ApplicationException("The subscription id for this campaign has not been set.");

            if (campaign.Guid == null)
            {
                //Make sure this tracking code hasn't been used
                CmsCampaign check = GetByTrackingCode(campaign.SubscriptionId, campaign.TrackingCode);
                if (check != null)
                    throw new ArgumentException("The tracking code: " + campaign.TrackingCode + " has already been associated with camapaign: " + check.Name + " and may not be used again.");

                campaign.Guid = System.Guid.NewGuid().ToString();
            }

            CmsCampaignDao dao = new CmsCampaignDao();
            using (Transaction tx = new Transaction())
            {
                dao.Save<CmsCampaign>(campaign);
                tx.Commit();
            }
        }
コード例 #2
0
 public IList<CmsCampaign> GetCampaigns(Data.Guid siteGuid)
 {
     CmsCampaignDao dao = new CmsCampaignDao();
     return dao.FindBySite(siteGuid);
 }
コード例 #3
0
 public CmsCampaign GetByTrackingCode(Data.Guid siteGuid, String trackingCode)
 {
     CmsCampaignDao dao = new CmsCampaignDao();
     return dao.FindByTrackingCodeAndSite(siteGuid, trackingCode);
 }
コード例 #4
0
 public CmsCampaign GetCampaign(Data.Guid siteGuid, Data.Guid campaignGuid)
 {
     CmsCampaignDao dao = new CmsCampaignDao();
     return dao.FindBySiteAndGuid(siteGuid,campaignGuid);
 }
コード例 #5
0
        public void Delete(Data.Guid siteGuid, Data.Guid guid)
        {
            CmsCampaign campaign = GetCampaign(siteGuid, guid);
            if (campaign != null)
            {
                //Delete it from the subscription itself
                SubscriptionManager.RemovePhoneFromSubscription(CurrentSite.Guid, campaign.PhoneNumber);

                CmsCampaignDao dao = new CmsCampaignDao();
                using (Transaction tx = new Transaction())
                {
                    dao.Delete<CmsCampaign>(campaign);
                    tx.Commit();
                }
            }
        }