public ActionResult Create(Models.Voter voter) { if (Session["EmailId"] == null) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { DataAccess.Voter vInfo = new DataAccess.Voter() { VoterName = voter.VoterName, Age = voter.Age, DOB = voter.DOB, Gender = voter.Gender, State = voter.State, City = voter.City, EmailId = voter.EmailId, MobileNumber = voter.MobileNumber }; VoterRepository repo = new VoterRepository(); bool result = repo.AddVoter(vInfo); if (!result) { return(View("Error")); } } return(RedirectToAction("Index", "Voter")); }
public ActionResult Edit(Models.Voter voter) { if (Session["EmailId"] == null) { return(RedirectToAction("Index", "Home")); } DataAccess.Voter eVoter = new DataAccess.Voter() { VoterId = voter.VoterId, VoterName = voter.VoterName, Age = voter.Age, DOB = voter.DOB, Gender = voter.Gender, City = voter.City, State = voter.State, EmailId = voter.EmailId, MobileNumber = voter.MobileNumber }; VoterRepository repo = new VoterRepository(); bool result = repo.UpdateVoterDetails(eVoter); if (!result) { return(View("Error")); } return(RedirectToAction("Index", "Voter")); }