Example #1
0
        public IActionResult Candidates()
        {
            APIHandler webHandler = new APIHandler();
            Candidates candidates = webHandler.GetCandidates();

            foreach (var item in candidates.results)
            {
                if (dbContext.Candidates.Where(c => c.candidate_id.Equals(item.candidate_id)).Count() == 0)
                {
                    dbContext.Candidates.Add(item);
                }
            }
            dbContext.SaveChanges();


            return(View(candidates));
        }
Example #2
0
 public void Save()
 {
     _electionContext.SaveChanges();
 }
Example #3
0
 public virtual T Add(T t)
 {
     _dbSet.Add(t);
     _context.SaveChanges();
     return(t);
 }