private void LoadControlManageCandidates() { var electionKey = _ThisControl.SafeGetElectionKey(); var officeKey = _ThisControl.SafeGetOfficeKey(); var table = Elections.GetOneElectionOffice(electionKey, officeKey); var candidates = table.Rows.Cast <DataRow>() .Where(row => !row.IsRunningMate()) .OrderBy(row => row.OrderOnBallot()) .ThenBy(row => row.PoliticianKey(), StringComparer.OrdinalIgnoreCase) .ToList(); _ThisControl.PageFeedback.AddInfo( $"{candidates.Count} candidate{candidates.Count.Plural()} loaded."); if (candidates.Count == 0) { _ThisControl.Message.RemoveCssClass("hidden"); _ThisControl.Message.InnerHtml = "No candidates were found for this office."; } else { _ThisControl.Message.AddCssClasses("hidden"); foreach (var candidate in candidates) { var li = new HtmlLi { ID = "candidate-" + candidate.PoliticianKey(), ClientIDMode = ClientIDMode.Static }.AddTo( _ThisControl.ControlAddCandidatesCandidateList); var outerDiv = new HtmlDiv().AddTo(li, "outer shadow-2"); CreateCandidateEntry(candidate, DataMode.ManageCandidates) .AddTo(outerDiv); var runningMateKey = candidate.RunningMateKey(); if (!candidate.IsRunningMateOffice() || Elections.IsPrimaryElection(electionKey)) { continue; } DataRow runningMate = null; if (!string.IsNullOrWhiteSpace(runningMateKey)) { runningMate = table.Rows.Cast <DataRow>() .FirstOrDefault(row => row.PoliticianKey() .IsEqIgnoreCase(runningMateKey)); } if (runningMate == null) { CreateNoRunningMateEntry() .AddTo(outerDiv); } else { CreateCandidateEntry(runningMate, DataMode.ManageCandidates, candidate.PartyCode()) .AddTo(outerDiv); } } } }
protected override string GetCurrentValue() { if (Column == "AdImageChanged" || Column == "AdImageUpdated") { return("False"); // always unchanged from db } return(ToDisplay(ElectionsPoliticians.GetColumn(ElectionsPoliticians.GetColumn(Column), ThisControl.SafeGetElectionKey(), ThisControl.SafeGetOfficeKey(), ThisControl.AdSetupCandidate.Value))); }