public static Candidate GetCandidateById(int candidateId) { CandidateRepository repository = new CandidateRepository(); Candidate item = new Candidate(); item.CandidateId = candidateId; item = repository.FindOne(item); item.ContactInfo = string.Empty; if (!string.IsNullOrEmpty(item.Address)) { item.ContactInfo += "Address : " + item.Address + "/n"; } if (!string.IsNullOrEmpty(item.CVMail)) { item.ContactInfo += "Mail : " + item.CVMail; } if (item.Inactive.HasValue) { if(item.Inactive.Value) item.InactiveString = "inactif"; else item.InactiveString = "actif"; } return item; }
private static IList<Candidate> GetCandidateFromReader(SqlDataReader reader) { List<Candidate> result = new List<Candidate>(); while (reader.Read()) { Candidate item = new Candidate(); item.CandidateId = (int)reader["CandidatID"]; item.Unit = reader["Unit"] as string; item.LastName = reader["Nom"] as string; item.FirstName = reader["Prenom"] as string; item.Address = reader["Adresse"] as string; item.ZipCode = reader["CVMail"] as string; if (!(reader["inactif"] is DBNull)) { item.Inactive = (bool?) reader["inactif"]; } if (item.Inactive.HasValue) { if (item.Inactive.Value) item.InactiveString = "inactif"; else item.InactiveString = "actif"; } if (!(reader["DateModif"] is DBNull)) { item.LastModifDate = (DateTime)reader["DateModif"]; } result.Add(item); } return result; }