public ActionResult Create(Results results)
        {
            if (ModelState.IsValid)
            {
                db.ElectionResults.Add(results);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(results);
        }
 public ActionResult Edit(Results results)
 {
     if (ModelState.IsValid)
     {
         db.Entry(results).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(results);
 }
        public void parsecsvTest2()
        {
            StreamReader reader = new StreamReader("C:\\Users\\DB\\Documents\\GitHub\\EF-Group-Project\\datasets\\test_files\\testResults.csv", true);

            AllDataParser target = new DataParse();
            target.setStreamSource(reader);
            Results r = new Results();
            r.ElectionType = "Mayoral";
            r.ElectionYear = 2006;
            r.WardNum = 1;
            r.NumVotes = 134;
            r.CandidateLastName = "Alexander";
            r.CandidateFirstName = "Michael";

            List<Results> expected = new List<Results>();
            expected.Add(r);
            expected.Add(r);
            expected.Add(r);

            List<Results> actual;
            actual = target.parseResults();

            //there are 3 values in the test file
            Assert.AreEqual(expected.Count, actual.Count);

            Results ElectionType = actual.Find(item => item.ElectionType == "Mayoral");

            Assert.IsNotNull(ElectionType);
        }
        // bring in results data
        List<Results> AllDataParser.parseResults()
        {
            List<Results> lst = new List<Results>();
            CsvReader csv = new CsvReader(reader, true);
            int fieldCount = csv.FieldCount;

            String[] headers = csv.GetFieldHeaders();

            while (csv.ReadNextRecord())
            {

                Results exObj = new Results();

                for (int i = 0; i < fieldCount; i++)
                {
                    if (headers[i].Equals("id"))
                    {
                    }
                    else if (headers[i].Equals("ELECTIONTYPE"))
                    {
                        exObj.ElectionType = csv[i];
                    }
                    else if (headers[i].Equals("ELECTIONYEAR"))
                    {
                        exObj.ElectionYear = Convert.ToInt32(csv[i]);
                    }
                    else if (headers[i].Equals("WARDNUM"))
                    {
                        exObj.WardNum = Convert.ToInt32(csv[i]);
                    }
                    else if (headers[i].Equals("NUMVOTES"))
                    {
                        exObj.NumVotes = Convert.ToInt32(csv[i]);
                    }
                    else if (headers[i].Equals("CANDIDATELASTNAME"))
                    {
                        exObj.CandidateLastName = csv[i];
                    }
                    else if (headers[i].Equals("CANDIDATEFIRSTNAME"))
                    {
                        exObj.CandidateFirstName = csv[i];
                    }

                }

                lst.Add(exObj);
            }
            return lst;
        }