Example #1
0
        protected void BtnSave_Click(Object sender, EventArgs e)
        {
            CmsCampaign campaign = CampaignManager.Instance.GetCampaign(this.campaignGuid);

            //Attempt to load the element based upon the guid
            CmsCampaignElement element = CampaignManager.Instance.Elements.GetElement(this.ElementGuid.Value,this.campaignGuid);
            if (element == null)
                element = new CmsCampaignElement();

            int priority = 1;
            Int32.TryParse(this.TxtPriority.Text, out priority);

            element.Campaign = campaign;
            element.Name = this.TxtName.Text;
            element.Placement = this.LstPlacement.SelectedValue;
            element.Priority = priority;
            element.Content = this.TxtContent.Text;

            StringBuilder pages = new StringBuilder();
            foreach (ListItem item in this.LstSelectedPages.Items)
            {
                if (item.Selected)
                    pages.AppendFormat("{0}{1}", item.Value, CmsCampaignElement.ElementSeparator);
            }
            element._Pages = pages.ToString();

            CampaignManager.Instance.Elements.Save(element);
            this.ElementGuid.Value = element.Guid;

            this.LoadExisting();
            this.LstExistingElements.SelectedValue = element.Guid;

            CurrentSite.RefreshPageCache();
            this.LblStatus.Text = "Save Successful. Changes may take a minute or two to be visible on your site.";
        }
Example #2
0
 public void Save(CmsCampaignElement element)
 {
     CmsCampaignElementDao dao = new CmsCampaignElementDao();
     using (Transaction tx = new Transaction())
     {
         dao.Save<CmsCampaignElement>(element);
         tx.Commit();
     }
 }
Example #3
0
 public void Delete(CmsCampaignElement element)
 {
     if (element != null)
     {
         CmsCampaignElementDao dao = new CmsCampaignElementDao();
         using (Transaction tx = new Transaction())
         {
             dao.Delete<CmsCampaignElement>(element);
             tx.Commit();
         }
     }
 }