protected override bool Update(object newValue) { var isResultRecorded = false; var isPassed = false; switch (newValue as string) { case "unknown": // defaults are ok break; case "passed": isResultRecorded = true; isPassed = true; break; case "defeated": isResultRecorded = true; break; default: return(false); } Referendums.UpdateIsResultRecorded(isResultRecorded, Page.GetElectionKey(), Page.GetBallotMeasureKey()); Referendums.UpdateIsPassed(isPassed, Page.GetElectionKey(), Page.GetBallotMeasureKey()); if (ChangesList) { ListChanged = true; } return(true); }
public void GetData(string electionKey, string countyCode, string district, string place, string elementary, string secondary, string unified, string cityCouncil, string countySupervisors, string schoolDistrictDistrict) { DataTable = Referendums.GetBallotReportData(electionKey, countyCode, district, place, elementary, secondary, unified, cityCouncil, countySupervisors, schoolDistrictDistrict); }
protected override bool Update(object newValue) { var orderChanged = false; var stringValue = newValue.ToString(); var electionKey = Page.GetElectionKey(); if (!IsNullOrWhiteSpace(stringValue)) { var referendumKeys = stringValue .Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries) .Select(s => s.Substring(s.LastIndexOf('-') + 1)); var referendumOrder = 10; foreach (var referendumKey in referendumKeys) { var oldReferendumOrder = Referendums.GetOrderOnBallot(electionKey, referendumKey, 0); if (referendumOrder != oldReferendumOrder) { Referendums.UpdateOrderOnBallot(referendumOrder, electionKey, referendumKey); LogDataChange.LogUpdate(Referendums.Column.OrderOnBallot, oldReferendumOrder.ToString(CultureInfo.InvariantCulture), referendumOrder.ToString(CultureInfo.InvariantCulture), DateTime.UtcNow, electionKey, referendumKey); orderChanged = true; } referendumOrder += 10; } } LoadControl(); return(orderChanged); }
protected override string GetCurrentValue() { var column = Referendums.GetColumn(Column); var value = Referendums.GetColumn(column, Page.GetElectionKey(), Page.GetBallotMeasureKey()); return(value == null ? string.Empty : ToDisplay(value)); }
private void GetLocalElections(Control container, string countyElectionKey) { var stateCode = Elections.GetStateCodeFromKey(countyElectionKey); var countyCode = Elections.GetCountyCodeFromKey(countyElectionKey); var stateElectionKey = Elections.GetStateElectionKeyFromKey(countyElectionKey); // We get a dictionary of locals with elections that match the stateElectionKey // Key: localCode; Value: local electionKey // Locals without an election will not be in the dictionary var localElectionDictionary = ElectionsOffices.GetLocalElections(stateElectionKey, countyCode); // We can't forget the Ballot Measures... var localReferendumDictionary = Referendums.GetLocalElections(stateElectionKey, countyCode); // merge them into the first dictionary foreach (var kvp in localReferendumDictionary) { if (!localElectionDictionary.ContainsKey(kvp.Key)) { localElectionDictionary.Add(kvp.Key, kvp.Value); } } if (localElectionDictionary.Count == 0) { return; } // We also get a dictionary of all local names for the county var localNamesDictionary = LocalDistricts.GetNamesDictionary(stateCode, countyCode); new HtmlDiv { InnerText = "Local District Elections" }.AddTo(container, "accordion-header"); var content = new HtmlDiv().AddTo(container, "category-content accordion-content"); // For reporting we filter only locals with elections and sort by name, var locals = localNamesDictionary.Where( kvp => localElectionDictionary.ContainsKey(kvp.Key)) .OrderBy(kvp => kvp.Value) .ToList(); foreach (var kvp in locals) { var localCode = kvp.Key; var localName = kvp.Value; var localElectionKey = localElectionDictionary[localCode]; new HtmlDiv { InnerText = localName }.AddTo(content, "accordion-header"); new ElectionReportResponsive().GenerateReport(ReportUser, localElectionKey) .AddTo(content, "accordion-content"); } }
protected override bool Update(object newValue) { var column = Referendums.GetColumn(Column); Referendums.UpdateColumn(column, newValue, Page.GetElectionKey(), Page.GetBallotMeasureKey()); if (ChangesList) { ListChanged = true; } return(true); }
protected override string GetCurrentValue() { if (!Referendums.GetIsResultRecorded(Page.GetElectionKey(), Page.GetBallotMeasureKey(), false)) { return("unknown"); } return(Referendums.GetIsPassed(Page.GetElectionKey(), Page.GetBallotMeasureKey(), false) ? "passed" : "defeated"); }
private void GetCountyElections(Control container, string stateElectionKey) { var stateCode = Elections.GetStateCodeFromKey(stateElectionKey); // We get a dictionary of counties with elections that match the stateElectionKey // Key: countyCode; Value: county electionKey // Counties without an election will not be in the dictionary // We include local elections too, to account for situations where there is no county // election but there are local elections. var countyElectionDictionary = ElectionsOffices.GetCountyAndLocalElections(stateElectionKey); // We can't forget the Ballot Measures... var countyReferendumDictionary = Referendums.GetCountyAndLocalElections(stateElectionKey); // merge them into the first dictionary foreach (var kvp in countyReferendumDictionary) { if (!countyElectionDictionary.ContainsKey(kvp.Key)) { countyElectionDictionary.Add(kvp.Key, kvp.Value); } } if (countyElectionDictionary.Count == 0) { return; } new HtmlDiv { InnerText = "County Elections" }.AddTo(container, "accordion-header"); var content = new HtmlDiv().AddTo(container, "category-content accordion-content"); // For reporting we start with all counties for the state (it will be in // order by county name) and select only those in the election dictionary. var counties = CountyCache.GetCountiesByState(stateCode) .Where(countyElectionDictionary.ContainsKey) .ToList(); // each county report is in its own accordion foreach (var countyCode in counties) { var countyName = CountyCache.GetCountyName(stateCode, countyCode); var countyElectionKey = countyElectionDictionary[countyCode]; new HtmlDiv { InnerText = countyName }.AddTo(content, "accordion-header"); new ElectionReportResponsive().GenerateReport(ReportUser, countyElectionKey) .AddTo(content, "accordion-content"); } }
private void AddBallotMeasure(string referendumKey) { var electionKey = GetElectionKey(); var electionKeyState = Elections.GetStateElectionKeyFromKey(electionKey); var stateCode = Elections.GetStateCodeFromKey(electionKey); var countyCode = Elections.GetCountyCodeFromKey(electionKey); var localKey = Elections.GetLocalKeyFromKey(electionKey); var orderOnBallot = Referendums.GetNextOrderOnBallot(electionKey); Referendums.Insert(electionKey, referendumKey, electionKeyState, stateCode, countyCode, localKey, orderOnBallot, Empty, Empty, Empty, Empty, Empty, Empty, false, false, false); }
private static void DeleteAllDistictReferences(string stateCode, string localKey) { Elections.DeleteByStateCodeLocalKey(stateCode, localKey); ElectionsIncumbentsRemoved.DeleteByStateCodeLocalKey(stateCode, localKey); ElectionsOffices.DeleteByStateCodeLocalKey(stateCode, localKey); ElectionsPoliticians.DeleteByStateCodeLocalKey(stateCode, localKey); QuestionsJurisdictions.DeleteByIssueLevelStateCodeCountyOrLocal(Issues.IssueLevelLocal, stateCode, localKey); Offices.DeleteByStateCodeLocalKey(stateCode, localKey); //OfficesAllIdentified.DeleteByStateCodeLocalKey(stateCode, localKey); OfficesOfficials.DeleteByStateCodeLocalKey(stateCode, localKey); Referendums.DeleteByStateCodeLocalKey(stateCode, localKey); }
public static string FindStateCode() { // reworked to eliminate ViewState references var stateCode = QueryState; if (IsNullOrWhiteSpace(stateCode)) { if (IsPublicPage) { stateCode = UrlManager.CurrentDomainDataCode; } else if (IsMasterUser || IsAdminUser) { stateCode = UserStateCode; if (IsNullOrWhiteSpace(stateCode)) { stateCode = Elections.GetStateCodeFromKey(QueryElection); } if (IsNullOrWhiteSpace(stateCode)) { stateCode = Offices.GetStateCodeFromKey(QueryOffice); } if (IsNullOrWhiteSpace(stateCode)) { stateCode = Politicians.GetStateCodeFromKey(QueryId); } if (IsNullOrWhiteSpace(stateCode)) { stateCode = Issues.GetStateCodeFromKey(QueryIssue); } if (IsNullOrWhiteSpace(stateCode)) { stateCode = Referendums.GetStateCodeFromKey(QueryReferendum); } } else if (IsPoliticianUser) { stateCode = Politicians.GetStateCodeFromKey(UserPoliticianKey); } else if (IsPartyUser) { stateCode = Parties.GetStateCodeFromKey(UserPartyKey); } } return(!IsNullOrWhiteSpace(stateCode) && (StateCache.IsValidStateOrFederalCode(stateCode) || GetPage <SecureAdminPage>()?.NonStateCodesAllowed.Contains(stateCode) == true) ? stateCode : Empty); }
// ReSharper disable MemberCanBePrivate.Global // ReSharper disable MemberCanBeProtected.Global // ReSharper disable UnusedMember.Global // ReSharper disable UnusedMethodReturnValue.Global // ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable UnassignedField.Global #endregion ReSharper disable public static void GetReport(Control container, string countyElectionKey, bool openAll = false) { var stateCode = Elections.GetStateCodeFromKey(countyElectionKey); var countyCode = Elections.GetCountyCodeFromKey(countyElectionKey); var stateElectionKey = Elections.GetStateElectionKeyFromKey(countyElectionKey); // We get a dictionary of locals with elections that match the stateElectionKey // Key: localKey; Value: local electionKey // Locals without an election will not be in the dictionary // We can't forget the Ballot Measures... var localKeys = LocalDistricts.GetLocalKeysForCounty(stateCode, countyCode); var localElectionDictionary = ElectionsOffices.GetLocalElections(stateElectionKey, countyCode, localKeys); var localReferendumDictionary = Referendums.GetLocalElections(stateElectionKey, countyCode, localKeys); // merge them into the first dictionary foreach (var kvp in localReferendumDictionary) if (!localElectionDictionary.ContainsKey(kvp.Key)) localElectionDictionary.Add(kvp.Key, kvp.Value); if (localElectionDictionary.Count == 0) return; // We also get a dictionary of all local names for the county var localNamesDictionary = LocalDistricts.GetNamesDictionary(stateCode, countyCode); new HtmlDiv {InnerText = "Local District Elections"}.AddTo(container, "accordion-header"); var content = new HtmlDiv().AddTo(container, "local-anchors accordion-content"); // For reporting we filter only locals with elections and sort by name, var locals = localNamesDictionary.Where(kvp => localElectionDictionary.ContainsKey(kvp.Key)) .OrderBy(kvp => kvp.Value, new AlphanumericComparer()) .ToList(); // get a dictionary of other county names for multiple counties var otherCountyNames = LocalIdsCodes.FormatOtherCountyNamesDictionary(stateCode, countyCode, locals.Select(l => l.Key)); foreach (var kvp in locals) { var localKey = kvp.Key; var localName = kvp.Value; var otherCounties = otherCountyNames[localKey]; if (!IsNullOrWhiteSpace(otherCounties)) localName += $" (also in {otherCounties})"; var localElectionKey = localElectionDictionary[localKey]; CreatePublicElectionAnchor(localElectionKey, localName, openAll) .AddTo(content, "local-anchor"); } }
// ReSharper disable MemberCanBePrivate.Global // ReSharper disable MemberCanBeProtected.Global // ReSharper disable UnusedMember.Global // ReSharper disable UnusedMethodReturnValue.Global // ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable UnassignedField.Global #endregion ReSharper disable public static void GetReport(Control container, string stateElectionKey, bool openAll = false) { var stateCode = Elections.GetStateCodeFromKey(stateElectionKey); // We get a dictionary of counties with elections that match the stateElectionKey // Key: countyCode; Value: county electionKey // Counties without an election will not be in the dictionary // Update: we now include local elections too, to account for situations where there is no county // election but there are local elections. var countyElectionDictionary = ElectionsOffices.GetCountyAndLocalElections(stateElectionKey); // We can't forget the Ballot Measures... var countyReferendumDictionary = Referendums.GetCountyAndLocalElections(stateElectionKey); // merge them into the first dictionary foreach (var kvp in countyReferendumDictionary) { if (!countyElectionDictionary.ContainsKey(kvp.Key)) { countyElectionDictionary.Add(kvp.Key, kvp.Value); } } if (countyElectionDictionary.Count == 0) { return; } new HtmlDiv { InnerText = "County Elections" }.AddTo(container, "accordion-header"); var content = new HtmlDiv().AddTo(container, "local-anchors accordion-content"); // For reporting we start with all counties for the state (it will be in // order by county name) and select only those in the election dictionary. var counties = CountyCache.GetCountiesByState(stateCode) .Where(countyElectionDictionary.ContainsKey) .ToList(); foreach (var countyCode in counties) { var countyName = CountyCache.GetCountyName(stateCode, countyCode); var countyElectionKey = countyElectionDictionary[countyCode]; CreatePublicElectionAnchor(countyElectionKey, countyName, openAll) .AddTo(content, "local-anchor"); } }
private static string EncodeBallotChoices(object choices, int logId) { // offices separated by $ // candidates separated by | // writeIn indicated by * string result = null; if (choices is Dictionary <string, object> officeDictionary) { var offices = new List <string> { logId.ToString(CultureInfo.InvariantCulture) }; foreach (var officeKey in officeDictionary.Keys) { if (!(officeDictionary[officeKey] is Dictionary <string, object> candidateDictionary)) // it's a ballot measure { var key = Referendums.GetIdByReferendumKey(officeKey); var val = officeDictionary[officeKey] as string; // > indicates ballot measure offices.Add($"{key}|>{val}"); } else { var keys = new List <string> { Offices.GetId(officeKey).ToString() }; foreach (var politicianKey in candidateDictionary.Keys) { if (candidateDictionary[politicianKey] is int) { // politician key keys.Add(Politicians.GetId(politicianKey).ToString()); } else { if (candidateDictionary[politicianKey] is string writeIn) { writeIn = Uri.EscapeUriString(Regex.Replace(writeIn, "[$|]", "-")); keys.Add($"*{writeIn}"); } } } offices.Add(Join("|", keys)); } }
protected void Page_Load(object sender, EventArgs e) { _ElectionDescription = PageCache.Elections.GetElectionDesc(_ElectionKey); var table = Referendums.GetData(_ElectionKey, _ReferendumKey); if (table.Count == 1) { _Referendum = table[0]; } var spacedOutTitle = _Referendum.ReferendumTitle.ReplaceNewLinesWithSpaces(); Title = Format(TitleTag, spacedOutTitle, _ElectionDescription, PublicMasterPage.SiteName); MetaDescription = Format(MetaDescriptionTag, spacedOutTitle, _ElectionDescription); if (_Referendum != null) { CreateReport(); } }
private void ReportReferendums(string electionKey) { var referendums = Referendums.GetElectionReportSummaryData(electionKey); if (referendums.Count == 0) { return; } // ReSharper disable once PossibleNullReferenceException (new HtmlDiv().AddTo(ReportContainer, "category-title referendum-header accordion-header") as HtmlGenericControl).InnerHtml = "Referendums and Ballot Measures"; var container = new HtmlDiv().AddTo(ReportContainer, "category-content referendums-content accordion-content"); foreach (var referendum in referendums) { ReportOneReferendum(container, referendum); } }
private void AddBallotMeasure(string referendumKey) { var electionKey = GetElectionKey(); var electionKeyState = Elections.GetStateElectionKeyFromKey(electionKey); var electionKeyCounty = Elections.GetCountyElectionKeyFromKey(electionKey); var electionKeyLocal = Elections.GetLocalElectionKeyFromKey(electionKey); var stateCode = Elections.GetStateCodeFromKey(electionKey); var countyCode = Elections.GetCountyCodeFromKey(electionKey); var localCode = Elections.GetLocalCodeFromKey(electionKey); var orderOnBallot = Referendums.GetNextOrderOnBallot(electionKey); Referendums.Insert(electionKey: electionKey, referendumKey: referendumKey, electionKeyState: electionKeyState, electionKeyCounty: electionKeyCounty, electionKeyLocal: electionKeyLocal, stateCode: stateCode, countyCode: countyCode, localCode: localCode, orderOnBallot: orderOnBallot, referendumTitle: string.Empty, referendumDescription: string.Empty, referendumDetail: string.Empty, referendumDetailUrl: string.Empty, referendumFullText: string.Empty, referendumFullTextUrl: string.Empty, isReferendumTagForDeletion: false, isPassed: false, isResultRecorded: false); }
public void GetData(string electionKey, string countyCode) { DataTable = Referendums.GetBallotReportData(electionKey, countyCode); }
private static void GetCountyElections(Control container, string stateElectionKey) { var stateCode = Elections.GetStateCodeFromKey(stateElectionKey); // We get a dictionary of counties with elections that match the stateElectionKey // Key: countyCode; Value: countyElectionKey // Counties without an election will not be in the dictionary // We include local elections too, to account for situations where there is no county // election but there are local elections. var countyElectionDictionary = ElectionsOffices.GetCountyAndLocalElections(stateElectionKey); // We can't forget the Ballot Measures... var countyReferendumDictionary = Referendums.GetCountyAndLocalElections(stateElectionKey); // merge them into the first dictionary foreach (var kvp in countyReferendumDictionary) { if (!countyElectionDictionary.ContainsKey(kvp.Key)) { countyElectionDictionary.Add(kvp.Key, kvp.Value); } } if (countyElectionDictionary.Count == 0) { return; } // For reporting we start with all counties for the state (it will be in // order by county name) and select only those in the election dictionary. var counties = CountyCache.GetCountiesByState(stateCode) .Where(countyElectionDictionary.ContainsKey).ToList(); var multiCountySection = new PlaceHolder(); multiCountySection.AddTo(container); // each county report is in its own accordion foreach (var countyCode in counties) { var countyName = CountyCache.GetCountyName(stateCode, countyCode); var countyElectionKey = countyElectionDictionary[countyCode]; var electionReport = new ElectionReportResponsive(); var countyReport = electionReport.GenerateReport(countyElectionKey, true, multiCountySection); for (var inx = 0; inx < countyReport.Controls.Count; inx += 2) { // this will always be a state report (for county reports, GenerateReport // is called directly. Inject the county name into the office title header for context var header = countyReport.Controls[inx] as HtmlContainerControl; header?.Controls.Add( new HtmlP { InnerText = countyName }.AddCssClasses("county-message")); } // move them to the content while (countyReport.Controls.Count > 0) { container.Controls.Add(countyReport.Controls[0]); } } }
private static void GetLocalElections(Control container, string countyElectionKey, Control multiCountySection = null) { var stateCode = Elections.GetStateCodeFromKey(countyElectionKey); var countyCode = Elections.GetCountyCodeFromKey(countyElectionKey); var stateElectionKey = Elections.GetStateElectionKeyFromKey(countyElectionKey); // We get a dictionary of locals with elections that match the stateElectionKey // Key: localKey; Value: local electionKey // Locals without an election will not be in the dictionary var localElectionDictionary = ElectionsOffices.GetLocalElections(stateElectionKey, countyCode); // We can't forget the Ballot Measures... var localReferendumDictionary = Referendums.GetLocalElections(stateElectionKey, countyCode); // merge them into the first dictionary foreach (var kvp in localReferendumDictionary) { if (!localElectionDictionary.ContainsKey(kvp.Key)) { localElectionDictionary.Add(kvp.Key, kvp.Value); } } if (localElectionDictionary.Count == 0) { return; } // We also get a dictionary of all local names for the county var localNamesDictionary = LocalDistricts.GetNamesDictionary(stateCode, countyCode); // For reporting we filter only locals with elections and sort by name, var locals = localNamesDictionary .Where(kvp => localElectionDictionary.ContainsKey(kvp.Key)) .OrderBy(kvp => kvp.Value, new AlphanumericComparer()).ToList(); // Get all counties for the locals NB: the counties are pre-sorted by county name var countiesForLocals = LocalIdsCodes.FindCountiesWithNames(stateCode, locals.Select(kvp => kvp.Key)); foreach (var kvp in locals) { var localKey = kvp.Key; var localName = kvp.Value; var localElectionKey = localElectionDictionary[localKey]; var countiesForLocal = countiesForLocals[localKey]; var electionReport = new ElectionReportResponsive(); var localReport = electionReport.GenerateReport(localElectionKey, true); // this will be either a state or county report (for local reports, GenerateReport // is called directly) //for either county or state, inject the name of the local district into the office // if this is an office-title oe a referendum header for (var inx = 0; inx < localReport.Controls.Count; inx += 2) { var header = localReport.Controls[inx] as HtmlContainerControl; if (header?.HasClass("office-title") == true || header?.HasClass("referendum-header") == true) { header.Controls.AddAt(0, new HtmlSpan { InnerText = $"{localName}, " }.AddCssClasses("local-name")); } } //switch (reportLevel) //{ //case ReportLevel.StateLevel: // { while (localReport.Controls.Count > 0) { if (countiesForLocal.Length > 1 && multiCountySection != null) { // if the county is the first in the counties, inject a multi-county message // and move the pair (header and content) to the multi-counties section. // Otherwise, discard it (it's a duplicate) if (countyCode == countiesForLocal[0].Value) { //var countyMessage = "Parts of this district are in" + // $" {LocalIdsCodes.FormatCountyNames(countiesForLocal, true)}"; //var header = localReport.Controls[0] as HtmlContainerControl; //header?.Controls.Add( // new HtmlP { InnerText = countyMessage }.AddCssClasses("county-message")); //Debug.Assert(multiCountySection != null, "multiCountySection != null"); multiCountySection.Controls.Add(localReport.Controls[0]); multiCountySection.Controls.Add(localReport.Controls[0]); } else { localReport.Controls.RemoveAt(0); localReport.Controls.RemoveAt(0); } } else { // move the pair (header and content) to the outer content container.Controls.Add(localReport.Controls[0]); container.Controls.Add(localReport.Controls[0]); } } // } // break; //case ReportLevel.CountyLevel: // { //var first = true; //while (localReport.Controls.Count > 0) //{ // // for multi-county districts, inject an "other counties" message into the // // first office header if multi county // var countyMessage = Empty; // if (first && countiesForLocal.Length > 1) // countyMessage = "Parts of this local district are also in" + // $" {LocalIdsCodes.FormatCountyNames(countiesForLocal, true, countyCode)}"; // var header = localReport.Controls[0] as HtmlContainerControl; // if (!IsNullOrWhiteSpace(countyMessage)) // header?.Controls.Add( // new HtmlP { InnerText = countyMessage }.AddCssClasses("county-message")); // first = false; // // move the pair (header and content) to the outer content // container.Controls.Add(localReport.Controls[0]); // container.Controls.Add(localReport.Controls[0]); //} //} //break; //} } }
protected void Page_Load(object sender, EventArgs e) { Server.ScriptTimeout = 1800; var electionKey = Request.QueryString["election"]; var csvType = Request.QueryString["type"]; var includeCandidates = csvType != "BM"; var includeCandidateInfo = csvType == "NA" || csvType == "WA"; var includeAnswers = csvType == "OA" || csvType == "WA"; var includeBallotMeasures = csvType == "BM"; if (IsNullOrWhiteSpace(electionKey)) { throw new VoteException("Election key is missing."); } var electionDescription = Elections.GetElectionDesc(electionKey); if (IsNullOrWhiteSpace(electionDescription)) { throw new VoteException("Election key is invalid."); } // make sure it's a valid filename var invalidFileChars = Path.GetInvalidFileNameChars(); electionDescription = Regex.Replace(electionDescription, ".", match => new[] { ' ', ',', '"', '\'' }.Contains(match.Value[0]) || invalidFileChars.Contains(match.Value[0]) ? "_" : match.Value); electionDescription = Regex.Replace(electionDescription, "__+", "_"); // get the data var table = includeBallotMeasures ? Referendums.GetElectionCsvReferendumData(electionKey) : ElectionsPoliticians.GetElectionCsvCandidateData(electionKey); // if we're including answers, get the answers data for each office in the election var qas = new List <QuestionAndAnswer>(); var columns = new List <dynamic>(); if (includeAnswers) { var answers = new List <DataRow>(); // get a list of all offices in the election var allOfficeKeys = table.Rows.OfType <DataRow>().Select(r => r.OfficeKey()).Distinct() .ToList(); // collect all the answers foreach (var officeKey in allOfficeKeys) { var oldAnswerCutoff = ElectionsOffices.GetOldAnswerCutoffDate(electionKey, officeKey); // the GroupBy is to eliminate duplicate answers if a question is in more than one issue answers.AddRange(ElectionsPoliticians.GetCompareCandidateIssuesNew(electionKey, officeKey) .Rows.OfType <DataRow>() .GroupBy(r => new { PoliticianKey = r.PoliticianKey(), QuestionKey = r.QuestionKey(), Sequence = r.Sequence() }) .Select(g => g.First())); // convert the answers to QuestionAndAnswer format foreach (var p in answers.GroupBy(r => r.PoliticianKey())) { qas.AddRange(ResponsiveIssuesReport.SplitOutVideos(ResponsiveIssuesReport.GetQuestionAndAnswerList(p, Politicians.GetData(p.Key)[0], false)).Where(qa => qa.ResponseDate > oldAnswerCutoff)); } } // analyze qas to determine which topic columns we need to include columns.AddRange(qas .GroupBy(qa => new { qa.QuestionKey, IsYouTube = !IsNullOrWhiteSpace(qa.YouTubeUrl) }).Select( g => new { g.Key.QuestionKey, g.Key.IsYouTube, Topic = $"{g.First().Question}{(g.Key.IsYouTube ? " Video" : Empty)}" }).OrderBy(q => q.Topic)); } // create the csv string csv; using (var ms = new MemoryStream()) { var streamWriter = new StreamWriter(ms); var csvWriter = new SimpleCsvWriter(); // write headers csvWriter.AddField("Jurisdiction"); csvWriter.AddField("State Code"); if (csvType != "OK") { csvWriter.AddField("County"); csvWriter.AddField("City or District"); csvWriter.AddField("Election Name"); csvWriter.AddField("Election Date"); csvWriter.AddField("VoteUSA Election Id"); } if (includeCandidates && csvType != "OK") { csvWriter.AddField("Office"); csvWriter.AddField("Office Class"); csvWriter.AddField("District"); csvWriter.AddField("VoteUSA Office Id"); csvWriter.AddField("Running Mate?"); csvWriter.AddField("Candidate"); csvWriter.AddField("First Name"); csvWriter.AddField("Middle Name"); csvWriter.AddField("Nickname"); csvWriter.AddField("Last Name"); csvWriter.AddField("Suffix"); csvWriter.AddField("Party"); csvWriter.AddField("VoteUSA Id"); } if (csvType == "OK") { csvWriter.AddField("County Code"); csvWriter.AddField("County"); csvWriter.AddField("Local Key"); csvWriter.AddField("Local Name"); csvWriter.AddField("Election Key"); csvWriter.AddField("Office Key"); csvWriter.AddField("Office"); csvWriter.AddField("Politician Key"); csvWriter.AddField("Politician Password"); csvWriter.AddField("Candidate"); csvWriter.AddField("Party Code"); csvWriter.AddField("Ad Enabled"); csvWriter.AddField("YouTube Video Url"); csvWriter.AddField("YouTube Channel or Playlist Url"); csvWriter.AddField("Compare Candidates Url"); csvWriter.AddField("Type"); csvWriter.AddField("Date"); csvWriter.AddField("Amount"); csvWriter.AddField("Email"); csvWriter.AddField("Banner Ad Url"); } if (includeCandidateInfo) { csvWriter.AddField("Intro Url"); csvWriter.AddField("Photo100 Url"); csvWriter.AddField("Photo200 Url"); csvWriter.AddField("Photo300 Url"); csvWriter.AddField("Postal Street Address"); csvWriter.AddField("Postal City, State Zip"); csvWriter.AddField("Phone"); csvWriter.AddField("Email"); csvWriter.AddField("Date of Birth"); } if (!includeAnswers && !includeBallotMeasures && csvType != "OK") { csvWriter.AddField("General Philosophy"); csvWriter.AddField("Personal and Family"); csvWriter.AddField("Education"); csvWriter.AddField("Profession"); csvWriter.AddField("Military"); csvWriter.AddField("Civic"); csvWriter.AddField("Political Experience"); csvWriter.AddField("Religious Affiliation"); csvWriter.AddField("Accomplishment and Awards"); } if (includeCandidateInfo) { csvWriter.AddField("Website Url"); csvWriter.AddField("Facebook Url"); csvWriter.AddField("YouTube Url"); csvWriter.AddField("Flickr Url"); csvWriter.AddField("Twitter Url"); csvWriter.AddField("RSS Feed Url"); csvWriter.AddField("Wikipedia Url"); csvWriter.AddField("BallotPedia Url"); csvWriter.AddField("Vimeo Url"); csvWriter.AddField("Google+ Url"); csvWriter.AddField("LinkedIn Url"); csvWriter.AddField("Pinterest Url"); csvWriter.AddField("Blogger Url"); csvWriter.AddField("Podcast Url"); csvWriter.AddField("Instagram Url"); csvWriter.AddField("GoFundMe Url"); csvWriter.AddField("Crowdpac Url"); } if (includeAnswers) { foreach (var column in columns) { csvWriter.AddField(column.Topic); } } if (includeBallotMeasures) { csvWriter.AddField("Ballot Measure Title"); csvWriter.AddField("Ballot Measure Description"); csvWriter.AddField("Ballot Measure Detail"); csvWriter.AddField("Ballot Measure Detail URL"); csvWriter.AddField("Ballot Measure Full Text"); csvWriter.AddField("Ballot Measure Full Text URL"); csvWriter.AddField("Ballot Measure Passed"); } csvWriter.Write(streamWriter); var stateCode = Elections.GetStateCodeFromKey(electionKey); // do a first pass to get counties for all locals var allLocals = new List <string>(); foreach (var row in table.Rows.Cast <DataRow>()) { if (!IsNullOrWhiteSpace(row.LocalKey())) { allLocals.Add(row.LocalKey()); } } var countiesForLocals = LocalIdsCodes.FindCountiesWithNames(stateCode, allLocals.Distinct()); var rows = table.Rows.Cast <DataRow>(); if (csvType == "OK") { rows = rows.OrderBy(r => r.OfficeLevel()) //.ThenBy(r => r.DistrictCode()) //.ThenBy(r => r.OfficeOrderWithinLevel()) //.ThenBy(r => r.OfficeLine1()) //.ThenBy(r => r.OfficeLine2()) .ThenBy(r => Offices.FormatOfficeName(r), MixedNumericComparer.Instance) .ThenBy(r => r.OrderOnBallot()) .ThenBy(r => r.PoliticianKey(), StringComparer.OrdinalIgnoreCase) .ThenBy(r => r.IsRunningMate()); } foreach (var row in rows) { string jurisdiction; var politicianKey = Empty; if (includeBallotMeasures) { if (!IsNullOrWhiteSpace(row.LocalKey())) { jurisdiction = "Local"; } else if (!IsNullOrWhiteSpace(row.CountyCode())) { jurisdiction = "County"; } else { jurisdiction = "State"; } } else { politicianKey = row.IsRunningMate() ? row.RunningMateKey() : row.PoliticianKey(); switch (Offices.GetElectoralClass(row.OfficeClass())) { case ElectoralClass.USPresident: case ElectoralClass.USSenate: case ElectoralClass.USHouse: jurisdiction = "Federal"; break; case ElectoralClass.USGovernors: case ElectoralClass.State: jurisdiction = "State"; break; case ElectoralClass.County: jurisdiction = "County"; break; case ElectoralClass.Local: jurisdiction = "Local"; break; default: jurisdiction = Empty; break; } } var photo100Url = Empty; if (includeCandidateInfo) { var qsc100 = new QueryStringCollection { { "id", politicianKey }, { "Col", "Headshot100" } }; var photo100Uri = UrlManager.GetSiteUri("image.aspx", qsc100); photo100Url = new UriBuilder(photo100Uri) { Scheme = Uri.UriSchemeHttps, Host = UrlManager.GetCanonicalLiveHostName(photo100Uri.Host), Port = 443 }.Uri.ToString(); } var photo200Url = Empty; if (includeCandidateInfo) { var qsc200 = new QueryStringCollection { { "id", politicianKey }, { "Col", "Profile200" } }; var photo200Uri = UrlManager.GetSiteUri("image.aspx", qsc200); photo200Url = new UriBuilder(photo200Uri) { Scheme = Uri.UriSchemeHttps, Host = UrlManager.GetCanonicalLiveHostName(photo200Uri.Host), Port = 443 }.Uri.ToString(); } var photo300Url = Empty; if (includeCandidateInfo) { var qsc300 = new QueryStringCollection { { "id", politicianKey }, { "Col", "Profile300" } }; var photo300Uri = UrlManager.GetSiteUri("image.aspx", qsc300); photo300Url = new UriBuilder(photo300Uri) { Scheme = Uri.UriSchemeHttps, Host = UrlManager.GetCanonicalLiveHostName(photo300Uri.Host), Port = 443 }.Uri.ToString(); } var introUrl = Empty; if (includeCandidateInfo) { var introUri = UrlManager.GetIntroPageUri(politicianKey); introUrl = new UriBuilder(introUri) { Scheme = Uri.UriSchemeHttps, Host = UrlManager.GetCanonicalLiveHostName(introUri.Host), Port = 443 }.Uri.ToString(); } var district = Empty; if (includeCandidates) { if (int.TryParse(row.DistrictCode(), out var districtNumber)) { district = districtNumber.ToString(CultureInfo.InvariantCulture); } } // convert to simple name if national var partyName = Empty; if (includeCandidates) { partyName = Parties.GetNationalPartyDescription(row.PartyCode(), row.PartyName()); } var county = IsNullOrWhiteSpace(row.County()) ? Empty : row.County(); var local = Empty; if (!IsNullOrWhiteSpace(row.LocalKey())) { local = row.LocalDistrict(); county = Join(", ", countiesForLocals[row.LocalKey()].Select(c => c.Text)); } csvWriter.AddField(jurisdiction); csvWriter.AddField(stateCode); if (csvType != "OK") { csvWriter.AddField(county); csvWriter.AddField(local); csvWriter.AddField(row.ElectionDescription()); csvWriter.AddField(row.ElectionDate().ToString("d")); csvWriter.AddField(row.ElectionKey()); } if (includeCandidates && csvType != "OK") { csvWriter.AddField(Offices.FormatOfficeName(row)); csvWriter.AddField(Offices.GetOfficeClassShortDescriptionExtended(row)); csvWriter.AddField(district); csvWriter.AddField(row.OfficeKey()); csvWriter.AddField(row.IsRunningMate() ? row.PoliticianKey() : Empty); csvWriter.AddField(Politicians.FormatName(row)); csvWriter.AddField(row.FirstName()); csvWriter.AddField(row.MiddleName()); csvWriter.AddField(row.Nickname()); csvWriter.AddField(row.LastName()); csvWriter.AddField(row.Suffix()); csvWriter.AddField(partyName); csvWriter.AddField(politicianKey); } if (csvType == "OK") { var youTubeVideoUrl = Empty; var youTubeAdWebAddress = row.AdUrl(); if (!IsNullOrWhiteSpace(youTubeAdWebAddress)) { youTubeVideoUrl = youTubeAdWebAddress.IsValidYouTubeVideoUrl() ? youTubeAdWebAddress : "channel or playlist"; } var adEnabled = Empty; if (!IsNullOrWhiteSpace(row.AdType())) { adEnabled = row.AdEnabled() ? "E" : "D"; } var compareUrl = UrlManager.GetCompareCandidatesPageUri(row.ElectionKey(), row.OfficeKey()) + $"&ad={politicianKey}"; csvWriter.AddField(row.CountyCode()); csvWriter.AddField(row.County().SafeString()); csvWriter.AddField(row.LocalKey()); csvWriter.AddField(row.LocalDistrict().SafeString()); csvWriter.AddField(row.ElectionKey()); csvWriter.AddField(row.OfficeKey()); csvWriter.AddField(Offices.FormatOfficeName(row.OfficeLine1(), row.OfficeLine2(), row.OfficeKey())); csvWriter.AddField(politicianKey); csvWriter.AddField(row.Password()); csvWriter.AddField(Politicians.FormatName(row)); csvWriter.AddField(row.PartyCode().SafeString()); csvWriter.AddField(adEnabled); csvWriter.AddField(youTubeVideoUrl); csvWriter.AddField(row.YouTubeWebAddress()); csvWriter.AddField($"=HYPERLINK(\"{compareUrl}\",\"{compareUrl}\")"); csvWriter.AddField(Empty); csvWriter.AddField(Empty); csvWriter.AddField(Empty); csvWriter.AddField(Empty); csvWriter.AddField(Empty); } if (includeCandidateInfo) { csvWriter.AddField(introUrl); csvWriter.AddField(photo100Url); csvWriter.AddField(photo200Url); csvWriter.AddField(photo300Url); csvWriter.AddField(row.PublicAddress()); csvWriter.AddField(row.PublicCityStateZip()); csvWriter.AddField(row.PublicPhone()); csvWriter.AddField(row.PublicEmail()); csvWriter.AddField(row.DateOfBirth().ToString("d")); } if (!includeAnswers && !includeBallotMeasures && csvType != "OK") { csvWriter.AddField(row.GeneralStatement().SafeString()); csvWriter.AddField(row.Personal().SafeString()); csvWriter.AddField(row.Education().SafeString()); csvWriter.AddField(row.Profession().SafeString()); csvWriter.AddField(row.Military().SafeString()); csvWriter.AddField(row.Civic().SafeString()); csvWriter.AddField(row.Political().SafeString()); csvWriter.AddField(row.Religion().SafeString()); csvWriter.AddField(row.Accomplishments().SafeString()); } if (includeCandidateInfo) { csvWriter.AddField(row.PublicWebAddress()); csvWriter.AddField(row.FacebookWebAddress()); csvWriter.AddField(row.YouTubeWebAddress()); csvWriter.AddField(row.FlickrWebAddress()); csvWriter.AddField(row.TwitterWebAddress()); csvWriter.AddField(row.RssFeedWebAddress()); csvWriter.AddField(row.WikipediaWebAddress()); csvWriter.AddField(row.BallotPediaWebAddress()); csvWriter.AddField(row.VimeoWebAddress()); csvWriter.AddField(row.GooglePlusWebAddress()); csvWriter.AddField(row.LinkedInWebAddress()); csvWriter.AddField(row.PinterestWebAddress()); csvWriter.AddField(row.BloggerWebAddress()); csvWriter.AddField(row.PodcastWebAddress()); csvWriter.AddField(row.WebstagramWebAddress()); csvWriter.AddField(row.GoFundMeWebAddress()); csvWriter.AddField(row.CrowdpacWebAddress()); } if (includeAnswers) { var data = qas.Where(qa => qa.PoliticianKey == politicianKey) .OrderByDescending(qa => qa.ResponseDate) .ToList(); foreach (var column in columns) { var response = data.FirstOrDefault(d => d.QuestionKey == column.QuestionKey && d.HasVideo == column.IsYouTube); var field = Empty; if (response != null) { if (response.HasVideo) { field = response.YouTubeUrl; } else { field = $"{response.Answer}" + $"\n\n{(IsNullOrWhiteSpace(response.AnswerSource) ? Empty : $" Source: {response.AnswerSource}")}" + $" ({response.AnswerDate:M/d/yyyy})"; } } csvWriter.AddField(field); } } if (includeBallotMeasures) { csvWriter.AddField(row.ReferendumTitle()); csvWriter.AddField(row.ReferendumDescription()); csvWriter.AddField(row.ReferendumDetail()); csvWriter.AddField(row.ReferendumDetailUrl()); csvWriter.AddField(row.ReferendumFullText()); csvWriter.AddField(row.ReferendumFullTextUrl()); csvWriter.AddField(row.IsPassed() ? "Y" : Empty); } csvWriter.Write(streamWriter); } streamWriter.Flush(); ms.Position = 0; csv = new StreamReader(ms).ReadToEnd(); } // download var filename = electionDescription; switch (csvType) { case "NA": filename += " without topics"; break; case "OA": filename += " - topics only"; break; case "WA": filename += " - all data including topics"; break; case "OK": filename += " - names and keys only"; break; case "BM": filename += " - Ballot Measures"; break; } Response.Clear(); Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", $"attachment;filename=\"{filename}.csv\""); Response.Write("\xfeff"); // BOM Response.Write(csv); Response.End(); }
private void CreateReport() { ReferendumTitle.InnerHtml = _Referendum.ReferendumTitle.ReplaceNewLinesWithParagraphs(); ReferendumSubTitle.InnerHtml = StateCache.GetStateName(Referendums.GetStateCodeFromKey(_ReferendumKey)) + " Ballot Measure / Referendum"; ReferendumSubTitle.Visible = false; // Link removed per Mantis 840 //new HtmlAnchor //{ // HRef = UrlManager.GetElectionPageUri(_ElectionKey).ToString(), // InnerText = _ElectionDescription //}.AddTo(ReferendumElection); ReferendumElection.InnerText = _ElectionDescription; var referendumDescription = _Referendum.ReferendumDescription; if (IsNullOrWhiteSpace(referendumDescription)) { ReferendumDescriptionLabel.Visible = false; ReferendumDescription.Visible = false; } else { ReferendumDescriptionLabel.InnerHtml = "Description:"; ReferendumDescription.InnerHtml = referendumDescription.ReplaceNewLinesWithParagraphs(); } var detail = _Referendum.ReferendumDetail; var detailUrl = _Referendum.ReferendumDetailUrl; if (IsNullOrWhiteSpace(detailUrl) && IsNullOrWhiteSpace(detail)) { ReferendumDetailLabel.Visible = false; ReferendumDetail.Visible = false; } else if (IsNullOrWhiteSpace(detail)) { ReferendumDetailLabel.InnerHtml = CreateAnchor(detailUrl, "Link to Detail", "no-print") .RenderToString(); ReferendumDetail.Visible = false; } else { ReferendumDetailLabel.InnerHtml = $"Detail {CreateAnchor(detailUrl, "(link to detail)", "parenthetical no-print").RenderToString()}"; ReferendumDetail.InnerHtml = detail.ReplaceNewLinesWithParagraphs(); } var fullText = _Referendum.ReferendumFullText; var fullTextUrl = _Referendum.ReferendumFullTextUrl; if (IsNullOrWhiteSpace(fullTextUrl) && IsNullOrWhiteSpace(fullText)) { ReferendumFullTextLabel.Visible = false; ReferendumFullText.Visible = false; } else if (IsNullOrWhiteSpace(fullText)) { ReferendumFullTextLabel.InnerHtml = CreateAnchor(fullTextUrl, "Link to Full Text", "no-print") .RenderToString(); ReferendumFullText.Visible = false; } else { ReferendumFullTextLabel.InnerHtml = $"Full Text {CreateAnchor(fullTextUrl, "(link to full text)").RenderToString()}"; ReferendumFullText.InnerHtml = fullText.ReplaceNewLinesWithParagraphs(); } }
protected void ButtonAddBallotMeasures_OnClick(object sender, EventArgs e) { AddBallotMeasuresRecased.Value = string.Empty; switch (AddBallotMeasuresReloading.Value) { case "loadballotmeasure": { AddBallotMeasuresReloading.Value = string.Empty; AddBallotMeasuresAnimate.Value = "true"; AddBallotMeasuresSubTabIndex.Value = "0"; var referendumKey = GetBallotMeasureKey(); if (referendumKey == "add") { HeadingAddBallotMeasuresBallotMeasure.InnerHtml = "Adding new ballot measure"; ContainerAddBallotMeasures.AddCssClasses("update-all"); _AddBallotMeasuresTabInfo.Reset(); FeedbackAddBallotMeasures.AddInfo("Blank form loaded for new ballot measure."); } else { HeadingAddBallotMeasuresBallotMeasure.InnerHtml = Referendums.GetReferendumTitle(GetElectionKey(), referendumKey); ContainerAddBallotMeasures.RemoveCssClass("update-all"); _AddBallotMeasuresTabInfo.LoadControls(); FeedbackAddBallotMeasures.AddInfo("Ballot measure loaded."); } RefreshAddBallotMeasuresTab(); } break; case "": AddBallotMeasuresAnimate.Value = "false"; var listChanged = false; if (GetBallotMeasureKey() == "add") { if (_AddBallotMeasuresTabInfo.Validate()) { // add, then update listChanged = true; Elections.ActualizeElection(GetElectionKey()); var newReferendumKey = Referendums.GetUniqueKey(GetElectionKey(), ControlAddBallotMeasuresReferendumTitle.GetValue()); AddBallotMeasure(newReferendumKey); ContainerAddBallotMeasures.RemoveCssClass("update-all"); SelectedBallotMeasureKey.Value = newReferendumKey; _AddBallotMeasuresTabInfo.Update(FeedbackAddBallotMeasures, false); RefreshAddBallotMeasuresTab(); FeedbackAddBallotMeasures.Clear(); FeedbackAddBallotMeasures.AddInfo("Ballot measure added."); } } else { // normal update _AddBallotMeasuresTabInfo.Update(FeedbackAddBallotMeasures); listChanged |= AddBallotMeasuresTabItem.ListChanged; RefreshAddBallotMeasuresTab(); } AddBallotMeasuresRecased.Value = string.Join("|", _AddBallotMeasuresTabInfo.WithWarning("recased") .Select(item => item.Description)); if (listChanged) { _SelectBallotMeasureControlInfo.LoadControls(); UpdatePanelSelectBallotMeasure.Update(); HeadingAddBallotMeasuresBallotMeasure.InnerHtml = Referendums.GetReferendumTitle(GetElectionKey(), GetBallotMeasureKey()); } break; default: throw new VoteException("Unknown reloading option"); } }
protected void ButtonDeleteDistricts_OnClick(object sender, EventArgs e) { switch (DeleteDistrictsReloading.Value) { case "reloading": { DeleteDistrictOverride.AddCssClasses("hidden"); ControlDeleteDistrictOverride.Checked = false; _DeleteDistrictsTabInfo.ClearValidationErrors(); DeleteDistrictsReloading.Value = Empty; PopulateLocalDistrictDropdown(); _DeleteDistrictsTabInfo.LoadControls(); FeedbackDeleteDistricts.AddInfo("Delete Districts information loaded."); } break; case "": { // normal update DeleteDistrictOverride.AddCssClasses("hidden"); _DeleteDistrictsTabInfo.ClearValidationErrors(); var localKey = ControlDeleteDistrictsLocalKey.GetValue(); var localDistrict = LocalDistricts.GetLocalDistrictByStateCodeLocalKey(StateCode, localKey); var referenceList = new List <string>(); if (!ControlDeleteDistrictOverride.Checked) { // check for references in other counties var otherCounties = new List <string>(); foreach (var oc in LocalIdsCodes.GetOtherCountyReferences(StateCode, CountyCode, localKey) .Rows.OfType <DataRow>()) { otherCounties.Add(oc.County()); } // check for meaningful usages FormatReferences(referenceList, "Elections", Elections.CountByStateCodeLocalKey(StateCode, localKey)); FormatReferences(referenceList, "ElectionsOffices", ElectionsOffices.CountByStateCodeLocalKey(StateCode, localKey)); FormatReferences(referenceList, "ElectionsPoliticians", ElectionsPoliticians.CountByStateCodeLocalKey(StateCode, localKey)); FormatReferences(referenceList, "QuestionsJurisdictions", QuestionsJurisdictions.CountByIssueLevelStateCodeCountyOrLocal( Issues.IssueLevelLocal, StateCode, localKey)); FormatReferences(referenceList, "Offices", Offices.CountByStateCodeLocalKey(StateCode, localKey)); FormatReferences(referenceList, "OfficesOfficials", OfficesOfficials.CountByStateCodeLocalKey(StateCode, localKey)); FormatReferences(referenceList, "Referendums", Referendums.CountByStateCodeLocalKey(StateCode, localKey)); if (referenceList.Count > 0 || otherCounties.Count > 0) { DeleteDistrictOverride.RemoveCssClass("hidden"); if (otherCounties.Count > 0) { FeedbackDeleteDistricts.PostValidationError(ControlDeleteDistrictsLocalKey, "The district is referenced in the following other counties. If you delete this" + " district it will be removed from the other counties also. Check the box to" + " override."); foreach (var oc in otherCounties) { FeedbackDeleteDistricts.AddError(oc); } } if (referenceList.Count > 0) { FeedbackDeleteDistricts.PostValidationError(ControlDeleteDistrictsLocalKey, "Cannot delete because the LocalKey is referenced in the following tables. Check the box to override."); foreach (var @ref in referenceList) { FeedbackDeleteDistricts.AddError(@ref); } } return; } } // delete ControlDeleteDistrictOverride.Checked = false; DeleteAllDistictReferences(StateCode, localKey); LocalDistricts.DeleteByStateCodeLocalKey(StateCode, localKey); // delete TigerPlacesCounties rows if type Vote -- these are not intrinsically tied // to county(s) var localIdsCodes = LocalIdsCodes.GetDataByStateCodeLocalKey(StateCode, localKey); Debug.Assert(localIdsCodes.Count == 1); if (localIdsCodes[0].LocalType == LocalIdsCodes.LocalTypeVote) { TigerPlacesCounties.DeleteByStateCodeTigerTypeTigerCode(StateCode, LocalIdsCodes.LocalTypeVote, localIdsCodes[0].LocalId); } LocalIdsCodes.DeleteByStateCodeLocalKey(StateCode, localKey); _DeleteDistrictsTabInfo.ClearValidationErrors(); PopulateLocalDistrictDropdown(); _DeleteDistrictsTabInfo.LoadControls(); NavigateJurisdictionUpdatePanel.Update(); NavigateJurisdiction.Initialize(); FeedbackDeleteDistricts.AddInfo( $"Local District {localDistrict} ({localKey}) deleted."); } break; default: throw new VoteException( $"Unknown reloading option: '{DeleteDistrictsReloading.Value}'"); } }
public override void LoadControl() { var table = Referendums.GetListData(Page.GetElectionKey()); BallotMeasureCount = Page.PopulateReferendumList(table); }