//private static HtmlAnchor CreateAdminOfficeAnchor(string officeKey, // string anchorText, string target) //{ // var a = new HtmlAnchor // { // HRef = SecureAdminPage.GetOfficePageEditUrl(officeKey), // Target = string.IsNullOrWhiteSpace(target) ? "office" : target, // InnerHtml = anchorText // }; // return a; //} private static HtmlAnchor CreateAdminPoliticianAnchor( PoliticiansAdminReportViewRow row, string anchorText, string target) { var a = new HtmlAnchor { HRef = SecureAdminPage.GetPoliticianPageUrl(row.PoliticianKey), Title = FormatPoliticianName(row) + " administration data edit form", InnerHtml = anchorText, Target = string.IsNullOrWhiteSpace(target) ? "politician" : target }; return(a); }
protected static HtmlAnchor CreateAdminPoliticianAnchor(DataRow politician, string anchorText, string target = "politician") { var a = new HtmlAnchor { HRef = SecureAdminPage.GetPoliticianPageUrl(politician.PoliticianKey()), Target = target, Title = Politicians.FormatName(politician) + " administration data edit form", InnerHtml = anchorText }; return(a); }
protected void ButtonAddNewCandidate_OnClick(object sender, EventArgs e) { bool validateDuplicates; bool.TryParse(AddCandidateValidateDuplicates.GetValue(), out validateDuplicates); AddCandidateDuplicatesHtml.Controls.Clear(); _AddNewCandidateSubTabInfo.ClearValidationErrors(); AddCandidateNewId.SetValue(string.Empty); // No actual updating here, just validation and reformatting _AddNewCandidateSubTabInfo.Update(FeedbackAddNewCandidate, false); if (FeedbackAddNewCandidate.ValidationErrorCount > 0) { return; } var stateCode = ControlAddNewCandidateStateCode.GetValue(); var firstName = ControlAddNewCandidateFName.GetValue(); var middleName = ControlAddNewCandidateMName.GetValue(); var nickname = ControlAddNewCandidateNickname.GetValue(); var lastName = ControlAddNewCandidateLName.GetValue(); var suffix = ControlAddNewCandidateSuffix.GetValue(); var formattedName = Politicians.FormatName(firstName, middleName, nickname, lastName, suffix); if (validateDuplicates) { var duplicatesHtml = Politicians.GetCandidateList(lastName, null, stateCode, null, true); AddCandidateDuplicatesHtml.Controls.Add(duplicatesHtml); if (duplicatesHtml.Controls.Count > 0) { // Set up the duplicates dialog AddCandidateFormattedName.SetValue(formattedName); AddCandidateStateName.SetValue(StateCache.GetStateName(stateCode)); FeedbackAddNewCandidate.PostValidationError(ControlAddNewCandidateLName, "Potential duplicate politician"); return; } } var newPoliticianKey = Politicians.GetUniqueKey(stateCode, lastName, firstName, middleName, suffix); AddCandidateNewId.SetValue(newPoliticianKey); // If it's a primary, get the party key from the election //var partyKey = "X"; var partyKey = string.Empty; // mantis 508 var electionKey = SafeGetElectionKey(); if (Elections.IsPrimaryElection(electionKey)) { partyKey = stateCode + Elections.GetNationalPartyCodeFromKey(electionKey); } Politicians.AddPolitician(newPoliticianKey, firstName, middleName, nickname, lastName, suffix, SafeGetOfficeKey(), partyKey, SecurePage.CreateUniquePassword()); LogDataChange.LogInsert(Politicians.TableName, VotePage.UserName, SecurePage.UserSecurityClass, DateTime.UtcNow, newPoliticianKey); ClearAddNewCandidate(); FeedbackAddNewCandidate.AddInfo("Politician " + formattedName + " was added."); if (Mode == DataMode.AddPoliticians) { FeedbackAddNewCandidate.AddInfo(new HtmlAnchor { InnerText = "Intro Page", HRef = UrlManager.GetIntroPageUri(newPoliticianKey).ToString(), Target = "Politician" }.RenderToString()); FeedbackAddNewCandidate.AddInfo(new HtmlAnchor { InnerText = "Politician Admin Page", HRef = SecureAdminPage.GetPoliticianPageUrl(newPoliticianKey), Target = "Politician" }.RenderToString()); } }