//public static string RenderAds(string electionKey, string officeKey, string adKey = null) //{ // var table = ElectionsPoliticians.GetAds(electionKey, officeKey, adKey); // if (table.Rows.Count == 0) return Empty; // var ads = new List<string>(); // var cache = VotePage.GetPageCache().Politicians; // foreach (var ad in table.Rows.OfType<DataRow>()) // { // var thumbnailId = IsNullOrWhiteSpace(ad.AdThumbnailUrl()) // ? ad.AdUrl().GetYouTubeVideoId() // : ad.AdThumbnailUrl().GetYouTubeVideoId(); // ads.Add(RenderOneAd(ad.PoliticianKey(), cache.GetPoliticianName(ad.PoliticianKey()), // ad.AdUrl(), thumbnailId, ad.AdSponsor(), ad.AdSponsorUrl(), ad.AdIsCandidateSponsored())); // } // return $"<div class=\"ads-outer\">{Join(Empty, ads)}</div>"; //} //public static string RenderOneAd(string politicianKey, string politicianName, // string videoUrl, string thumbnailId, string sponsor, string sponsorUrl, bool isCandidateSponsored) //{ // string paidMessage; // if (isCandidateSponsored) // paidMessage = // "Paid advertisement by <a target=\"_blank\"" + // $" href=\"{UrlManager.GetIntroPageUri(politicianKey)}\">candidate’s campaign</a>"; // else if (!IsNullOrWhiteSpace(sponsor)) // paidMessage = IsNullOrWhiteSpace(sponsorUrl) // ? $"Paid advertisement by {sponsor}" // : $"Paid advertisement by <a target=\"_blank\" href=\"{VotePage.NormalizeUrl(sponsorUrl)}\">" + // $"{sponsor}</a>"; // else // paidMessage = "Paid advertisement"; // return "<div class=\"ad-outer\"><div class=\"ad-inner\"><div class=\"ad-copy\">" + // $"<p class=\"ad-name\">{politicianName}</p>" + // $"<p class=\"paid-ad\">{paidMessage}</p></div>" + // $"<a class=\"video-wrapper-outer\" target=\"youtube\" href=\"{VotePage.NormalizeUrl(videoUrl)}\">" + // "<div class=\"video-container\"><div class=\"video-player\"><div>" + // $"<img class=\"video-thumb\" src=\"http://i.ytimg.com/vi/{thumbnailId}/hqdefault.jpg\"/>" + // "<div class=\"video-play-button\"></div></div></div></div></a>" + // $"<img class=\"ad-profile\" src=\"/Image.aspx?Id={politicianKey}&Col=Headshot100\"/>" + // "<div style=\"clear:both\"></div></div></div>"; //} public static string RenderAds(string electionKey, string officeKey, string adKey = null) { var table = ElectionsPoliticians.GetAds(electionKey, officeKey, adKey); if (table.Rows.Count == 0) { return(Empty); } var ads = new List <string>(); var cache = VotePage.GetPageCache().Politicians; foreach (var ad in table.Rows.OfType <DataRow>()) { var thumbnailId = IsNullOrWhiteSpace(ad.AdThumbnailUrl()) ? ad.AdUrl().GetYouTubeVideoId() : ad.AdThumbnailUrl().GetYouTubeVideoId(); ads.Add(RenderOneAd(electionKey, officeKey, ad.AdType(), ad.PoliticianKey(), cache.GetPoliticianName(ad.PoliticianKey()), ad.AdUrl(), thumbnailId, ad.AdSponsor(), ad.AdSponsorUrl(), ad.AdIsCandidateSponsored())); } return($"<div class=\"ads-outer\">{Join(Empty, ads)}</div>"); }