Example #1
0
        public void AddCandidate(Candidate candidate)
        {
            var ctx = new CandidateDbContext(_connectionString);

            ctx.Candidates.Add(candidate);
            ctx.SaveChanges();
        }
Example #2
0
        public void UpdateCandidate(Candidate candidate)
        {
            var ctx = new CandidateDbContext(_connectionString);

            ctx.Candidates.Attach(candidate);
            ctx.Entry(candidate).State = EntityState.Modified;
            ctx.SaveChanges();
        }
Example #3
0
        public List <int> getCounts()
        {
            var ctx    = new CandidateDbContext(_connectionString);
            var counts = new List <int>();

            counts.Add(ctx.Candidates.Where(c => c.Status == Status.Pending).Count());
            counts.Add(ctx.Candidates.Where(c => c.Status == Status.Confirmed).Count());
            counts.Add(ctx.Candidates.Where(c => c.Status == Status.Refused).Count());
            return(counts);
        }
Example #4
0
        public Candidate GetCandidate(int id)
        {
            var ctx = new CandidateDbContext(_connectionString);

            return(ctx.Candidates.FirstOrDefault(c => c.Id == id));
        }
Example #5
0
        public List <Candidate> GetCandidates(Status status)
        {
            var ctx = new CandidateDbContext(_connectionString);

            return(ctx.Candidates.Where(c => c.Status == status).ToList());
        }