Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.IncludeJs("~/js/ballot.js");

            _ElectionDescription = PageCache.Elections.GetElectionDesc(_ElectionKey);
            Title = Format(TitleTag, GetMetaTitle(), PublicMasterPage.SiteName);

            OgUrl.Attributes.Add("content", CanonicalUri.ToString());
            OgTitle.Attributes.Add("content", $"My choices for {_ElectionDescription}");
            OgDescription.Attributes.Add("content", "View the candidates I plan to vote for.");

            OgImage.Attributes.Add("content",
                                   UrlManager.GetSiteUri("/images/designs/Vote-USA/fbbanner2.png").ToString());
            OgImageWidth.Attributes.Add("content", "250");
            OgImageHeight.Attributes.Add("content", "250");

            try
            {
                var metaContent = GetMetaTitle();
                MetaDescription = metaContent;
                MetaKeywords    = metaContent;

                BallotReportResponsive.GetReport(QueryElection, QueryCongress, QueryStateSenate,
                                                 QueryStateHouse, QueryCounty, QueryDistrict, QueryPlace, QueryElementary,
                                                 QuerySecondary, QueryUnified, QueryCityCouncil, QueryCountySupervisors,
                                                 QuerySchoolDistrictDistrict, out var officeContests).AddTo(ReportPlaceHolder);
                var ballotMeasures = BallotReferendumReportResponsive.GetReport(QueryElection, QueryCounty,
                                                                                QueryDistrict, QueryPlace, QueryElementary, QuerySecondary, QueryUnified,
                                                                                QueryCityCouncil, QueryCountySupervisors, QuerySchoolDistrictDistrict)
                                     .AddTo(ReferendumReportPlaceHolder);
                ballotMeasures.AddTo(ReferendumReportPlaceHolder);
                CreateHeading(officeContests.Count, ballotMeasures.Controls.Count > 0);

                // tag body with key for persistent selections
                var body             = Master.FindControl("Body") as HtmlGenericControl;
                var stateElectionKey = Elections.GetStateElectionKeyFromKey(QueryElection)
                                       .ToUpperInvariant();
                // ReSharper disable once PossibleNullReferenceException
                body.Attributes.Add("data-election", stateElectionKey);
                var electionDate = DateTime.ParseExact(Elections.GetElectionDateStringFromKey(stateElectionKey), "yyyyMMdd",
                                                       CultureInfo.InvariantCulture);
                //var showAd = electionDate.AddDays(1) > DateTime.Today;
                var showAd = true;
                body.Attributes.Add("data-ad", showAd ? "Y" : "N");

                // for a single contest election we add a special class and also include the candidate comparison info
                if (officeContests.Count == 1 && ballotMeasures.Controls.Count == 0)
                {
                    body.AddCssClasses("single-contest");
                    body.Attributes.Add("data-adelection", QueryElection);
                    body.Attributes.Add("data-adoffice", officeContests[0]);
                    CompareCandidatesReportResponsive.GetReport(_ElectionKey, officeContests[0], true)
                    .AddTo(ReportPlaceHolder);
                }
            }
            catch (Exception /*ex*/)
            {
                // ignored
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.IncludeJs("~/js/ballot.js");

            _ElectionDescription = PageCache.Elections.GetElectionDesc(_ElectionKey);
            Title = Format(TitleTag, GetMetaTitle(), PublicMasterPage.SiteName);

            OgUrl.Attributes.Add("content", CanonicalUri.ToString());
            OgTitle.Attributes.Add("content", $"My choices for {_ElectionDescription}");
            OgDescription.Attributes.Add("content", "View the candidates I plan to vote for.");

            OgImage.Attributes.Add("content",
                                   UrlManager.GetSiteUri("/images/designs/Vote-USA/fbbanner2.png").ToString());
            OgImageWidth.Attributes.Add("content", "250");
            OgImageHeight.Attributes.Add("content", "250");

            try
            {
                var metaContent = GetMetaTitle();
                MetaDescription = metaContent;
                MetaKeywords    = metaContent;

                BallotReportResponsive.GetReport(QueryElection, QueryCongress, QueryStateSenate,
                                                 QueryStateHouse, QueryCounty, QueryDistrict, QueryPlace, QueryElementary,
                                                 QuerySecondary, QueryUnified, QueryCityCouncil, QueryCountySupervisors,
                                                 QuerySchoolDistrictDistrict, out var officeContests).AddTo(ReportPlaceHolder);
                var ballotMeasures = BallotReferendumReportResponsive.GetReport(QueryElection, QueryCounty,
                                                                                QueryDistrict, QueryPlace, QueryElementary, QuerySecondary, QueryUnified,
                                                                                QueryCityCouncil, QueryCountySupervisors, QuerySchoolDistrictDistrict)
                                     .AddTo(ReferendumReportPlaceHolder);
                ballotMeasures.AddTo(ReferendumReportPlaceHolder);
                CreateHeading(officeContests.Count, ballotMeasures.Controls.Count > 0);

                // tag body with key for persistent selections
                var body             = Master.FindControl("Body") as HtmlGenericControl;
                var stateElectionKey = Elections.GetStateElectionKeyFromKey(QueryElection)
                                       .ToUpperInvariant();
                // ReSharper disable once PossibleNullReferenceException
                body.Attributes.Add("data-election", stateElectionKey);
            }
            catch (Exception /*ex*/)
            {
                // ignored
            }
        }