public void Refuse(int candidateId)
 {
     using (var context = new CandidateDataContext(_connectionString))
     {
         context.ExecuteCommand("UPDATE Candidates SET Status = 2 WHERE Id={0}", candidateId);
     }
 }
 public int GetNumPending()
 {
     using (var context = new CandidateDataContext(_connectionString))
     {
         return(context.Candidates.ToList().Where(c => c.Status == 0).Count());
     }
 }
 public Candidate GetCandidateById(int id)
 {
     using (var context = new CandidateDataContext(_connectionString))
     {
         return(context.Candidates.ToList().FirstOrDefault(c => c.Id == id));
     }
 }
 public IEnumerable <Candidate> GetRefusedCandidates()
 {
     using (var context = new CandidateDataContext(_connectionString))
     {
         return(context.Candidates.ToList().Where(c => c.Status == Status.Refused));
     }
 }
 public void AddCandidate(Candidate c)
 {
     using (var context = new CandidateDataContext(_connectionString))
     {
         context.Candidates.InsertOnSubmit(c);
         context.SubmitChanges();
     }
 }
 public StatusCounts GetCounts()
 {
     using (var context = new CandidateDataContext(_connectionString))
     {
         var counts = new StatusCounts
         {
             Pending   = context.Candidates.ToList().Where(c => c.Status == Status.Pending).Count(),
             Refused   = context.Candidates.ToList().Where(c => c.Status == Status.Refused).Count(),
             Confirmed = context.Candidates.ToList().Where(c => c.Status == Status.Confirmed).Count(),
         };
         return(counts);
     }
 }