예제 #1
0
 public Candidates GetCandidate(int candidateId)
 {
     using (var context = new CandidateContext(_connectionString))
     {
         return(context.Candidates.FirstOrDefault(c => c.Id == candidateId));
     }
 }
예제 #2
0
 public IEnumerable <Candidates> GetCandidates(Status status)
 {
     using (var context = new CandidateContext(_connectionString))
     {
         return(context.Candidates.Where(c => c.Status == status).ToList());
     }
 }
예제 #3
0
 public int AddCandidate(Candidates candidate)
 {
     using (var context = new CandidateContext(_connectionString))
     {
         context.Candidates.Add(candidate);
         context.SaveChanges();
         return(candidate.Id);
     }
 }
예제 #4
0
 public void Update(int candidateId, Status status)
 {
     using (var context = new CandidateContext(_connectionString))
     {
         Candidates c = context.Candidates.FirstOrDefault(ca => ca.Id == candidateId);
         c.Status = status;
         context.Candidates.Attach(c);
         context.Entry(c).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
예제 #5
0
 public CandidateCount GetCandidateCount()
 {
     using (var context = new CandidateContext(_connectionString))
     {
         return(new CandidateCount
         {
             PendingCount = context.Candidates.Where(c => c.Status == Status.Pending).Count(),
             ConfirmedCount = context.Candidates.Where(c => c.Status == Status.Accepted).Count(),
             DeclinedCount = context.Candidates.Where(c => c.Status == Status.Declined).Count()
         });
     }
 }