public Candidates GetCandidate(int candidateId) { using (var context = new CandidateContext(_connectionString)) { return(context.Candidates.FirstOrDefault(c => c.Id == candidateId)); } }
public IEnumerable <Candidates> GetCandidates(Status status) { using (var context = new CandidateContext(_connectionString)) { return(context.Candidates.Where(c => c.Status == status).ToList()); } }
public int AddCandidate(Candidates candidate) { using (var context = new CandidateContext(_connectionString)) { context.Candidates.Add(candidate); context.SaveChanges(); return(candidate.Id); } }
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(); } }
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() }); } }