//private IEnumerable<ElectionsFutureRow> GetFutureElections(string stateCode) //{ // var key = stateCode + "|ElectionsFutureByState"; // var data = GetDataCache(key); // if (data == null) // { // data = ElectionsFuture.GetIdData(stateCode, string.Empty, string.Empty); // PutDataCache(key, data); // } // return data as ElectionsFutureTable; //} private string GetLocalizedOfficeName(string officeKey) { var officeTitle = string.Empty; if (!Offices.IsStateOrFederalOffice(officeKey)) { if (Offices.IsCountyOffice(officeKey)) { officeTitle += CountyCache.GetCountyName(Offices.GetStateCodeFromKey(officeKey), Offices.GetCountyCodeFromKey(officeKey)); } else { officeTitle += VotePage.GetPageCache() .LocalDistricts.GetLocalDistrict( Offices.GetStateCodeFromKey(officeKey), Offices.GetCountyCodeFromKey(officeKey), Offices.GetLocalCodeFromKey(officeKey)); } officeTitle += " "; } officeTitle += Offices.FormatOfficeName(PageCache.Offices.GetOfficeLine1(officeKey), PageCache.Offices.GetOfficeLine2(officeKey), officeKey); return(officeTitle); }
//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>"); }