/// <summary> /// Adds the specific asset to campaign. If the asset does not exist it is created. /// </summary> /// <param name="campaignId">ID of the campaign.</param> /// <param name="assetUrlGuid">Asset URL GUID.</param> public static void AddPageAsset(int campaignId, Guid assetUrlGuid) { var campaignAsset = CampaignAssetInfo.Provider.Get() .WhereEquals("CampaignAssetCampaignID", campaignId) .WhereEquals("CampaignAssetAssetGuid", assetUrlGuid) .ToList().FirstOrDefault(); /* If the assest already exists, then do not create it. */ if (campaignAsset != null) { return; } campaignAsset = new CampaignAssetInfo { CampaignAssetType = CampaignAssetUrlInfo.OBJECT_TYPE, CampaignAssetCampaignID = campaignId, CampaignAssetAssetGuid = assetUrlGuid, }; CampaignAssetInfo.Provider.Set(campaignAsset); var campaignAssetUrl = CampaignAssetUrlInfo.Provider.Get() .WhereEquals("CampaignAssetUrlGuid", assetUrlGuid) .ToList().FirstOrDefault(); if (campaignAssetUrl != null) { return; } var page = GetDocument(ContentItemIdentifiers.LANDINGPAGE_COFFEESAMPLES); campaignAssetUrl = new CampaignAssetUrlInfo { CampaignAssetUrlCampaignAssetID = campaignAsset.CampaignAssetID, CampaignAssetUrlGuid = assetUrlGuid, CampaignAssetUrlTarget = DocumentURLProvider.GetUrl(page).Replace("~", string.Empty), CampaignAssetUrlPageTitle = "Coffee samples" }; CampaignAssetUrlInfo.Provider.Set(campaignAssetUrl); }
/// <summary> /// Adds the specific asset to campaign. If the asset does not exist it is created. /// </summary> /// <param name="campaignId">ID of the campaign.</param> /// <param name="assetUrlGuid">Asset URL GUID.</param> public static void AddPageAsset(int campaignId, Guid assetUrlGuid) { var campaignAsset = CampaignAssetInfoProvider.GetCampaignAssets() .WhereEquals("CampaignAssetCampaignID", campaignId) .WhereEquals("CampaignAssetAssetGuid", assetUrlGuid) .ToList().FirstOrDefault(); /* If the assest already exists, then do not create it. */ if (campaignAsset != null) { return; } campaignAsset = new CampaignAssetInfo { CampaignAssetType = CampaignAssetUrlInfo.OBJECT_TYPE, CampaignAssetCampaignID = campaignId, CampaignAssetAssetGuid = assetUrlGuid, }; CampaignAssetInfoProvider.SetCampaignAssetInfo(campaignAsset); var campaignAssetUrl = CampaignAssetUrlInfoProvider.GetCampaignAssetUrls() .WhereEquals("CampaignAssetUrlGuid", assetUrlGuid) .ToList().FirstOrDefault(); if (campaignAssetUrl != null) { return; } var page = GetDocument("/Landing-pages/Coffee-samples"); campaignAssetUrl = new CampaignAssetUrlInfo { CampaignAssetUrlCampaignAssetID = campaignAsset.CampaignAssetID, CampaignAssetUrlGuid = assetUrlGuid, CampaignAssetUrlTarget = page.RelativeURL.Replace("~", string.Empty), CampaignAssetUrlPageTitle = "Coffee samples" }; CampaignAssetUrlInfoProvider.SetCampaignAssetUrlInfo(campaignAssetUrl); }
/// <summary> /// Creates newsletter if it does not exist. /// </summary> /// <param name="campaignId">ID of the campaign.</param> /// <param name="nodeGuid">Newsletter node guid.</param> private static void CreateNewsletterAsset(int campaignId, Guid nodeGuid) { var campaignAsset = CampaignAssetInfo.Provider.Get() .WhereEquals("CampaignAssetCampaignID", campaignId) .WhereEquals("CampaignAssetAssetGuid", nodeGuid) .ToList().FirstOrDefault(); if (campaignAsset != null) { return; } campaignAsset = new CampaignAssetInfo { CampaignAssetType = PredefinedObjectType.NEWSLETTERISSUE, CampaignAssetCampaignID = campaignId, CampaignAssetAssetGuid = nodeGuid, }; CampaignAssetInfo.Provider.Set(campaignAsset); }