Ejemplo n.º 1
0
        private void LoadDefaultDeadlines()
        {
            var defaultElectionKey = Elections.GetDefaultElectionKeyFromKey(GetElectionKey());
            var defaults           = ElectionsDefaults.GetData(defaultElectionKey).FirstOrDefault();

            foreach (var item in _ChangeDeadlinesTabInfo)
            {
                if (DataItemBase.FindControl(this,
                                             "Default" + ChangeDeadlinesTabItem.GroupName +
                                             item.Column) is HtmlContainerControl defaultControl)
                {
                    var val = (DateTime?)defaults?[item.Column] ?? DefaultDbDate;
                    var str = val == DefaultDbDate ? "<none>" : val.ToString("d");
                    defaultControl.InnerText = $"Default: {str}";
                }
            }
        }
Ejemplo n.º 2
0
        private void LoadDefaultText()
        {
            var defaultElectionKey = Elections.GetDefaultElectionKeyFromKey(GetElectionKey());
            var defaults           = ElectionsDefaults.GetData(defaultElectionKey).FirstOrDefault();

            foreach (var item in _ChangeInfoTabInfo)
            {
                if (DataItemBase.FindControl(this,
                                             $"Default{ChangeInfoTabItem.GroupName}{item.Column}") is HtmlContainerControl defaultControl)
                {
                    var val = defaults?[item.Column] as string;
                    var str = IsNullOrWhiteSpace(val) ? "<none>" : val;
                    defaultControl.InnerText           = $"Default: {str}";
                    defaultControl.Attributes["title"] =
                        WebUtility.HtmlEncode(defaultControl.InnerText);
                }
            }
        }
Ejemplo n.º 3
0
        private void CreateHeading(int officeContestsCount, bool hasBallotMeasures)
        {
            // Link removed per Mantis 840
            //new HtmlAnchor
            //{
            //  HRef = UrlManager.GetElectionPageUri(_ElectionKey).ToString(),
            //  InnerText = _ElectionDescription
            //}.AddTo(ElectionTitle);
            ElectionTitle.InnerText = _ElectionDescription;
            LocationInfo1.InnerHtml = LocationInfo2.InnerHtml =
                FormatLegislativeDistrictsFromQueryStringForHeading(true);

            var stateCode = Elections.GetStateCodeFromKey(QueryElection);

            if (officeContestsCount > 0 || hasBallotMeasures)
            {
            }
            else
            {
                InstructionsAccordion.Visible = false;
                Instructions.InnerText        = "There are no office contests or ballot measures for your legislative districts.";
            }

            if (officeContestsCount > 0 || hasBallotMeasures)
            {
                var additionalInfo = PageCache.Elections.GetElectionAdditionalInfo(QueryElection)
                                     .ReplaceNewLinesWithParagraphs();
                if (IsNullOrWhiteSpace(additionalInfo))
                {
                    additionalInfo =
                        ElectionsDefaults.GetElectionAdditionalInfo(
                            Elections.GetDefaultElectionKeyFromKey(QueryElection));
                }
                if (!IsNullOrWhiteSpace(additionalInfo))
                {
                    new LiteralControl(additionalInfo).AddTo(AdditionalInformation);
                }

                var ballotInstructions = PageCache.Elections.GetBallotInstructions(QueryElection);
                if (IsNullOrWhiteSpace(ballotInstructions))
                {
                    ballotInstructions =
                        ElectionsDefaults.GetBallotInstructions(
                            Elections.GetDefaultElectionKeyFromKey(QueryElection));
                }
                if (!IsNullOrWhiteSpace(ballotInstructions))
                {
                    new LiteralControl(ballotInstructions.ReplaceNewLinesWithParagraphs()).AddTo(
                        BallotInstructions);
                }

                var statesRow = States.GetData(stateCode).FirstOrDefault();
                if (statesRow != null)
                {
                    var controlsToAdd = new List <Control>();

                    if (!IsNullOrWhiteSpace(statesRow.PollHours))
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlEm {
                            InnerText = "Normal Polling Hours: "
                        });
                        controlsToAdd.Add(new LiteralControl(statesRow.PollHours));
                    }

                    if (!IsNullOrWhiteSpace(statesRow.PollHoursUrl))
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlAnchor
                        {
                            HRef      = NormalizeUrl(statesRow.PollHoursUrl),
                            Target    = "_blank",
                            InnerHtml = statesRow.State + " polling hours"
                        });
                    }

                    if (!IsNullOrWhiteSpace(statesRow.PollPlacesUrl))
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlAnchor
                        {
                            HRef      = NormalizeUrl(statesRow.PollPlacesUrl),
                            Target    = "_blank",
                            InnerHtml = statesRow.State + " polling places"
                        });
                    }

                    if (!IsNullOrWhiteSpace(statesRow.VoterRegistrationWebAddress))
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlAnchor
                        {
                            HRef      = NormalizeUrl(statesRow.VoterRegistrationWebAddress),
                            Target    = "_blank",
                            InnerHtml = statesRow.State + " voter registration page"
                        });
                    }

                    if (!IsNullOrWhiteSpace(statesRow.EarlyVotingWebAddress))
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlAnchor
                        {
                            HRef      = NormalizeUrl(statesRow.EarlyVotingWebAddress),
                            Target    = "_blank",
                            InnerHtml = statesRow.State + " early voting page"
                        });
                    }

                    if (!IsNullOrWhiteSpace(statesRow.VoteByMailWebAddress))
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlAnchor
                        {
                            HRef      = NormalizeUrl(statesRow.VoteByMailWebAddress),
                            Target    = "_blank",
                            InnerHtml = statesRow.State + " vote by mail page"
                        });
                    }

                    if (!IsNullOrWhiteSpace(statesRow.VoteByAbsenteeBallotWebAddress))
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlAnchor
                        {
                            HRef      = NormalizeUrl(statesRow.VoteByAbsenteeBallotWebAddress),
                            Target    = "_blank",
                            InnerHtml = statesRow.State + " absentee ballot page"
                        });
                    }

                    if (controlsToAdd.Count > 0)
                    {
                        var p = new HtmlP();
                        VotingInformation.Controls.Add(p);
                        foreach (var c in controlsToAdd)
                        {
                            p.Controls.Add(c);
                        }
                    }

                    var howVotingIsDone = Elections.IsPrimaryElection(QueryElection)
            ? statesRow.HowPrimariesAreDone
            : statesRow.HowVotingIsDone;

                    if (!IsNullOrWhiteSpace(howVotingIsDone))
                    {
                        VotingInformation.Controls.Add(
                            new LiteralControl(howVotingIsDone.ReplaceNewLinesWithParagraphs()));
                    }
                }

                var stateElectionKey = Elections.GetStateElectionKeyFromKey(QueryElection);
                var electionsRow     = Elections.GetData(stateElectionKey).FirstOrDefault();
                var defRow           = ElectionsDefaults
                                       .GetData(Elections.GetDefaultElectionKeyFromKey(stateElectionKey))
                                       .FirstOrDefault();
                if (electionsRow != null && defRow != null)
                {
                    var controlsToAdd = new List <Control>();

                    var registrationDeadline = electionsRow.RegistrationDeadline.IsDefaultDate()
            ? defRow.RegistrationDeadline
            : electionsRow.RegistrationDeadline;

                    var earlyVotingBegin = electionsRow.EarlyVotingBegin.IsDefaultDate()
            ? defRow.EarlyVotingBegin
            : electionsRow.EarlyVotingBegin;

                    var earlyVotingEnd = electionsRow.EarlyVotingEnd.IsDefaultDate()
            ? defRow.EarlyVotingEnd
            : electionsRow.EarlyVotingEnd;

                    var mailBallotBegin = electionsRow.MailBallotBegin.IsDefaultDate()
            ? defRow.MailBallotBegin
            : electionsRow.MailBallotBegin;

                    var mailBallotEnd = electionsRow.MailBallotEnd.IsDefaultDate()
            ? defRow.MailBallotEnd
            : electionsRow.MailBallotEnd;

                    var mailBallotDeadline = electionsRow.MailBallotDeadline.IsDefaultDate()
            ? defRow.MailBallotDeadline
            : electionsRow.MailBallotDeadline;

                    var absenteeBallotBegin = electionsRow.AbsenteeBallotBegin.IsDefaultDate()
            ? defRow.AbsenteeBallotBegin
            : electionsRow.AbsenteeBallotBegin;

                    var absenteeBallotEnd = electionsRow.AbsenteeBallotEnd.IsDefaultDate()
            ? defRow.AbsenteeBallotEnd
            : electionsRow.AbsenteeBallotEnd;

                    var absenteeBallotDeadline = electionsRow.AbsenteeBallotDeadline.IsDefaultDate()
            ? defRow.AbsenteeBallotDeadline
            : electionsRow.AbsenteeBallotDeadline;

                    if (!registrationDeadline.IsDefaultDate())
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlEm {
                            InnerText = "Registration Deadline: "
                        });
                        controlsToAdd.Add(new LiteralControl(registrationDeadline.ToShortDateString()));
                    }

                    if (!earlyVotingBegin.IsDefaultDate() || !earlyVotingEnd.IsDefaultDate())
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlEm {
                            InnerText = "Early Voting: "
                        });
                        var strings = new List <string>();
                        if (!earlyVotingBegin.IsDefaultDate())
                        {
                            strings.Add($"begins {earlyVotingBegin.ToShortDateString()}");
                        }
                        if (!earlyVotingEnd.IsDefaultDate())
                        {
                            strings.Add($"ends {earlyVotingEnd.ToShortDateString()}");
                        }
                        controlsToAdd.Add(new LiteralControl(Join(", ", strings)));
                    }

                    if (!mailBallotBegin.IsDefaultDate() || !mailBallotEnd.IsDefaultDate() ||
                        !mailBallotDeadline.IsDefaultDate())
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlEm {
                            InnerText = "Mail-In Ballots: "
                        });
                        var strings = new List <string>();
                        if (!mailBallotBegin.IsDefaultDate())
                        {
                            strings.Add($"begins {mailBallotBegin.ToShortDateString()}");
                        }
                        if (!mailBallotEnd.IsDefaultDate())
                        {
                            strings.Add($"last day to request {mailBallotEnd.ToShortDateString()}");
                        }
                        if (!mailBallotDeadline.IsDefaultDate())
                        {
                            strings.Add($"must be received by {mailBallotDeadline.ToShortDateString()}");
                        }
                        controlsToAdd.Add(new LiteralControl(Join(", ", strings)));
                    }

                    if (!absenteeBallotBegin.IsDefaultDate() || !absenteeBallotEnd.IsDefaultDate() ||
                        !absenteeBallotDeadline.IsDefaultDate())
                    {
                        if (controlsToAdd.Count > 0)
                        {
                            controlsToAdd.Add(new HtmlBreak());
                        }
                        controlsToAdd.Add(new HtmlEm {
                            InnerText = "Absentee Ballots: "
                        });
                        var strings = new List <string>();
                        if (!absenteeBallotBegin.IsDefaultDate())
                        {
                            strings.Add($"begins {absenteeBallotBegin.ToShortDateString()}");
                        }
                        if (!absenteeBallotEnd.IsDefaultDate())
                        {
                            strings.Add($"last day to request {absenteeBallotEnd.ToShortDateString()}");
                        }
                        if (!absenteeBallotDeadline.IsDefaultDate())
                        {
                            strings.Add(
                                $"must be received by {absenteeBallotDeadline.ToShortDateString()}");
                        }
                        controlsToAdd.Add(new LiteralControl(Join(", ", strings)));
                    }

                    if (controlsToAdd.Count > 0)
                    {
                        var p = new HtmlP();
                        VotingInformation.Controls.Add(p);
                        foreach (var c in controlsToAdd)
                        {
                            p.Controls.Add(c);
                        }
                    }
                }

                // Mantis 349: Show Incumbent always
                //if (
                //  StateCache.GetIsIncumbentShownOnBallots(
                //    Elections.GetStateCodeFromKey(QueryElection)))
                var span = new HtmlSpan().AddTo(AdditionalInfo, "incumbent-note");
                new LiteralControl("* before a candidate&rsquo;s name denotes incumbent").AddTo(span);
            }
        }