Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var substitutions = new Substitutions();

            if (DomainData.IsValidStateCode) // Single state
            {
                Title =
                    $"{PublicMasterPage.SiteName} | {substitutions.Substitute(TitleTagDefaultPageSingleStateDomain)}";
                MetaDescription = substitutions.Substitute(MetaDescriptionTagDefaultPageSingleStateDomain);
            }
            else // use the All states domain
            {
                Title =
                    $"{PublicMasterPage.SiteName} | {substitutions.Substitute(TitleTagDefaultPageAllStatesDomain)}";
                MetaDescription = substitutions.Substitute(MetaDescriptionTagDefaultPageAllStatesDomain);
            }

            // My Sample Ballot Buttons

            var             cookies   = LocationCookies.GetCookies();
            List <LinkInfo> links     = null;
            var             stateCode = DomainData.FromQueryStringOrDomain;

            if (cookies.IsValid)
            {
                links = GetRecentSampleBallotLinks(cookies);
            }
            ExplorerLinkBox.Visible = false;

            SetupHeading(cookies, links);

            if (DomainData.IsValidStateCode)
            {
                CreateUpcomingLinks(stateCode);
            }
            else
            {
                UpcomingLinkBox.Visible = false;
            }

            GetLinkBox(PresidentLinks, "US President and Vice-President",
                       ForResearchPage.GetPresidentLinks());
            GetLinkBox(SenateLinks, "US Senate",
                       ForResearchPage.GetSenateLinks());
            GetLinkBox(HouseLinks, "US House of Representatives",
                       ForResearchPage.GetHouseLinks());
            GetLinkBox(GovernorLinks,
                       "State Governors and Lieutenant Governors",
                       ForResearchPage.GetGovernorLinks());

            if (DomainData.IsValidStateCode)
            {
                ForResearchPage.AddStateLinksToDiv(ElectionResults, stateCode, false, false);
            }
            else
            {
                ElectionResultsLinkBox.Visible = false;
            }
        }
Example #2
0
        private static void GetLinkBox(Control linkBox, string title,
                                       IEnumerable <LinkInfo> links)
        {
            new HtmlDiv {
                InnerText = title
            }.AddTo(linkBox, "link-header");
            var div = new HtmlDiv().AddTo(linkBox, "links");

            ForResearchPage.AddLinksToLinkBox(div, links);
        }
Example #3
0
        private static void AddUpcomingLinksToDiv(Control div,
                                                  string stateCode)
        {
            var links = GetUpcomingLinks(stateCode);

            if (links.Count > 0)
            {
                ForResearchPage.AddLinksToLinkBox(div, links);
            }
            else
            {
                var p       = new HtmlP().AddTo(div);
                var message =
                    $"No {StateCache.GetStateName(stateCode)} upcoming election reports are available. " +
                    "Please check back later.";
                new LiteralControl(message).AddTo(p);
            }
        }