示例#1
0
 public Candidate GetCandidateById(int Id)
 {
     using (var context = new CandidateContext(_conn))
     {
         return(context.Candidates.FirstOrDefault(c => c.Id == Id));
     }
 }
示例#2
0
 public List <Candidate> GetCandidates()
 {
     using (var context = new CandidateContext(_conn))
     {
         return(context.Candidates.ToList());
     }
 }
示例#3
0
 public void UpdateStatus(Candidate c)
 {
     using (var context = new CandidateContext(_conn))
     {
         context.Update(c);
         context.SaveChanges();
     }
 }
示例#4
0
 public void Add(Candidate c)
 {
     using (var context = new CandidateContext(_conn))
     {
         context.Candidates.Add(c);
         context.SaveChanges();
     }
 }
示例#5
0
 public List <Candidate> GetCandidates(string status)
 {
     using (var context = new CandidateContext(_conn))
     {
         var statusLower = status.ToLower();
         return(context.Candidates.Where(c => c.Status.ToLower() == statusLower).ToList());
     }
 }
示例#6
0
        public CountsViewModel GetCounts()
        {
            using (var context = new CandidateContext(_conn))
            {
                var counts = new CountsViewModel();
                counts.pending   = GetCandidates("Pending").Count;
                counts.confirmed = GetCandidates("Confirmed").Count;
                counts.refused   = GetCandidates("Refused").Count;

                return(counts);
            }
        }