public ActionResult CountVote(Voter v) { var voter = Session["VoterId"].ToString(); var id = TempData["ID"].ToString(); var Candidate = db.Candidates.Single(x => x.Candidate_ID == id); string count = Candidate.Vote.ToString(); int num = int.Parse(count) + 1; TempData["num2"] = num.ToString(); var isVoted = Session["isVoted"].ToString(); if (isVoted == "False") { v = new Voter() { VoterId = voter, isVoted = true }; db.Voters.Attach(v); db.Entry(v).Property(x => x.isVoted).IsModified = true; db.SaveChanges(); return(RedirectToAction("Voting", "Voter")); } else { return(RedirectToAction("Home", "Home")); } }
public ActionResult Edit([Bind(Include = "Candidate_ID,Password,Name,Mobile_no,City,State,Email_id,Aadhar_Id,Party_id,DOB,Image")] Candidate candidate) { if (ModelState.IsValid) { db.Entry(candidate).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Party_id = new SelectList(db.Parties, "Party_ID", "Password", candidate.Party_id); return(View(candidate)); }