Beispiel #1
0
        protected void ButtonEditPolitician_OnClick(object sender, EventArgs e)
        {
            var toEdit        = GetPoliticianKeyToEdit();
            var politicianKey = toEdit.Key;

            CandidateHtml.Controls.Clear();
            var isRunningMate = !IsNullOrWhiteSpace(MainCandidateIfRunningMate.Value);

            if (Politicians.GetStateCodeFromKey(politicianKey) != "DC")
            {
                AddOnEditElement.AddCssClasses("hidden");
            }

            switch (EditPoliticianReloading.Value)
            {
            case "reloading":
            {
                EditPoliticianReloading.Value = Empty;
                ControlEditPoliticianPartyKey.Items.Clear();
                VotePage.LoadPartiesDropdown(Politicians.GetStateCodeFromKey(politicianKey),
                                             ControlEditPoliticianPartyKey, Empty, VotePage.PartyCategories.None,
                                             VotePage.PartyCategories.StateParties, VotePage.PartyCategories.NationalParties,
                                             VotePage.PartyCategories.NonParties);
                _EditPoliticianDialogInfo.LoadControls();
                FeedbackEditPolitician.AddInfo("Politician information loaded.");
                var href = SecurePoliticianPage.GetUpdateIntroPageUrl(politicianKey);
                UpdateIntroLink.HRef             = href;
                UpdateIntroLinkProfessional.HRef = href + "#bio2-ALLBio333333";
            }
            break;

            case "":
            {
                // normal update
                _EditPoliticianDialogInfo.ClearValidationErrors();
                _EditPoliticianDialogInfo.Update(FeedbackEditPolitician);
                var partyCodeToSuppress = Empty;
                if (isRunningMate)
                {
                    partyCodeToSuppress =
                        Parties.GetPartyCode(
                            Politicians.GetPartyKey(MainCandidateIfRunningMate.Value));
                }
                var row = Politicians.GetCandidateData(SafeGetElectionKey(), politicianKey,
                                                       isRunningMate);
                // use current dynamic IsIncumbent
                row["IsIncumbent"] = toEdit.ShowAsIncumbent;
                CandidateHtml.Controls.Add(CreateCandidateEntry(row, Mode, partyCodeToSuppress,
                                                                !isRunningMate && ElectionsPoliticians.ElectionKeyOfficeKeyPoliticianKeyExists(
                                                                    SafeGetElectionKey(), SafeGetOfficeKey(), politicianKey)));
            }
            break;

            default:
                throw new VoteException(
                          $"Unknown reloading option: '{EditPoliticianReloading.Value}'");
            }

            NameOnBallots.InnerText = PageCache.GetTemporary().Politicians
                                      .GetPoliticianName(politicianKey);
            UpdateIntroPage.SetPartyNameAndLink(ControlEditPoliticianPartyKey.GetValue(),
                                                PartyName);
        }