/// <summary> /// Retrieves basic profile information for a candidate. /// </summary> /// <param name="candidateID">The desired candidate's CFIS ID.</param> /// <returns>The requested candidate's profile information if found, otherwise null.</returns> public Candidate GetCandidate(string candidateID) { using (CandidateTds ds = new CandidateTds()) { using (CandidateTableAdapter ta = new CandidateTableAdapter()) { ta.FillBy(ds.Candidate, candidateID); } foreach (CandidateTds.CandidateRow row in ds.Candidate.Rows) { return(Parse(row)); } } return(null); }
/// <summary> /// Retrieves the full name of a candidate by CFIS ID. /// </summary> /// <param name="candidateID">The CFIS ID of the candidate to find.</param> /// <param name="formal">Whether or not to retrieve a formal name.</param> /// <returns>The full name of the specified candidate.</returns> public string GetCandidateName(string candidateID, bool formal) { if (string.IsNullOrEmpty(candidateID)) { return(string.Empty); } using (CandidateTds ds = new CandidateTds()) { using (CandidateNameTableAdapter ta = new CandidateNameTableAdapter()) { ta.Fill(ds.CandidateName, candidateID); } foreach (CandidateTds.CandidateNameRow row in ds.CandidateName) { return(Candidate.ToFullName(row.FirstName, row.LastName, string.IsNullOrWhiteSpace(row.MiddleInitial) ? null : row.MiddleInitial.Trim().ToCharArray()[0] as char?, formal)); } return(null); } }
/// <summary> /// Retrieves basic profile information for all known candidates. /// </summary> /// <returns>A collection of <see cref="Candidate"/> objects representing all known candidates indexed by CFIS ID.</returns> public Dictionary <string, Candidate> GetCandidates() { Dictionary <string, Candidate> candidates = new Dictionary <string, Candidate>(); using (CandidateTds ds = new CandidateTds()) { using (CandidateTableAdapter ta = new CandidateTableAdapter()) { ta.Fill(ds.Candidate); } foreach (CandidateTds.CandidateRow row in ds.Candidate.Rows) { Candidate c = Parse(row); if (c != null) { candidates.Add(c.ID, c); } } } return(candidates); }