public void Save(CmsCampaignElement element) { CmsCampaignElementDao dao = new CmsCampaignElementDao(); using (Transaction tx = new Transaction()) { dao.Save<CmsCampaignElement>(element); tx.Commit(); } }
/// <summary> /// Gets all of the campaign elements for the specified page /// </summary> /// <param name="cmsPage"></param> /// <returns></returns> public IDictionary<String, String> GetElementsForPage(Data.Model.Page.CmsPage cmsPage) { CmsCampaignElementDao dao = new CmsCampaignElementDao(); IList<CmsCampaignElement> elements = dao.FindByPageUrl(cmsPage.Url); Dictionary<String, IList<CmsCampaignElement>> groupings = new Dictionary<string, IList<CmsCampaignElement>>(); groupings["top"] = new List<CmsCampaignElement>(); groupings["middle"] = new List<CmsCampaignElement>(); groupings["bottom"] = new List<CmsCampaignElement>(); foreach (CmsCampaignElement element in elements) groupings[element.Placement].Add(element); Dictionary<String, String> results = new Dictionary<string, string>(); //Loop through each "group" and build up the elements foreach (String key in groupings.Keys) { StringBuilder builder = new StringBuilder(); IList<CmsCampaignElement> temp = groupings[key]; foreach (CmsCampaignElement item in temp) { builder.Append(@"<div class=""gooey-campaign-element"">").AppendLine(); builder.AppendLine(item.Content); builder.AppendFormat("</div>"); } results[key] = builder.ToString(); } return results; }
public CmsCampaignElement GetElement(Data.Guid elementGuid, Data.Guid expectedCampaignGuid = new Data.Guid()) { CmsCampaignElementDao dao = new CmsCampaignElementDao(); CmsCampaignElement element = dao.FindByElementGuid(elementGuid); if ((element != null) && (!expectedCampaignGuid.IsEmpty())) { if (!element.Campaign.Guid.Equals(expectedCampaignGuid.Value)) throw new ArgumentException("There was a problem retrieving the campaign element: Element belongs to campaign " + element.Campaign.Guid + ", but attempted retrieval for " + expectedCampaignGuid.Value); } return element; }
public IList<CmsCampaignElement> GetElements(Data.Guid campaignGuid) { CmsCampaignElementDao dao = new CmsCampaignElementDao(); return dao.FindByCampaignGuid(campaignGuid); }
public void Delete(CmsCampaignElement element) { if (element != null) { CmsCampaignElementDao dao = new CmsCampaignElementDao(); using (Transaction tx = new Transaction()) { dao.Delete<CmsCampaignElement>(element); tx.Commit(); } } }