private void FillInAdditionalInfo() { var additionalInfo = PageCache.Elections.GetElectionAdditionalInfo(_ElectionKey); if (string.IsNullOrWhiteSpace(additionalInfo)) { additionalInfo = ElectionsDefaults.GetElectionAdditionalInfo( Elections.GetDefaultElectionKeyFromKey(_ElectionKey)); } if (string.IsNullOrWhiteSpace(additionalInfo)) { AdditionalInfo.Visible = false; } else { AdditionalInfo.InnerHtml = additionalInfo.ReplaceBreakTagsWithSpaces().ReplaceNewLinesWithParagraphs(); AdditionalInfo.Visible = true; } }
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’s name denotes incumbent").AddTo(span); } }