public ActionResult UpdateVoterInfo(string VoterGUID, int?id) { ViewBag.message = TempData["message"]; ViewBag.success = TempData["success"]; if (VoterGUID != null) { VoterVM voterVM = new VoterVM(); if (voterVM.IsLogedIn(db, VoterGUID)) { voterVM.RefreshGUID(db); int test = Convert.ToInt32(id); Voter v = db.Voters.Where(x => x.VoterID == test).FirstOrDefault(); registerVoter.voterView = voterVM; registerVoter.VoterList = db.Voters.Where(x => x.VoterID == test).ToList(); TempData["voterVM"] = voterVM; ViewBag.ProvinceID = new SelectList(db.Provinces, "ProvinceID", "ProvinceName"); ViewBag.CityOrTownID = new SelectList(db.CityOrTowns, "CityOrTownID", "CityOrTownName"); ViewBag.SuburbID = new SelectList(db.Suburbs, "SuburbID", "SuburbName"); return(View(v)); } } else { TempData["message"] = "An Error Occured Please try again!"; return(RedirectToAction("VoterHomePage", new { VoterGUID = registerVoter.voterView.voter.GUID })); } return(View()); }
public ActionResult LogVoterIn(string IDNumber, string Password) { if (IDNumber.Length != 13) { TempData["Message"] = "Your ID number is not the right length"; return(RedirectToAction("VoterLogin")); } else { var IDNum = registerVoter.HashedData(IDNumber); var Pass = registerVoter.HashedData(Password); Voter u = db.Voters.Where(x => x.VoterIDNumber == IDNum && x.VoterPassword == Pass).FirstOrDefault(); if (u != null) { VoterVM voterVM = new VoterVM(); voterVM.voter = u; voterVM.RefreshGUID(db); TempData["voterVM"] = voterVM; return(RedirectToAction("VoterHomePage")); } else { TempData["Message"] = "Your ID number or password was incorect! Please try again!"; return(RedirectToAction("VoterLogin", "Voter")); } } }
public ActionResult doVoteProvincial(string VoterGUID, string id, string PartyID, string provinceID) { if (VoterGUID != null && PartyID != null && id != null) { VoterVM voterVM = new VoterVM(); if (voterVM.IsLogedIn(db, VoterGUID) && voterVM.voter.VoteProvinceStatus == false) { voterVM.RefreshGUID(db); VotingViewModel votingViewModel = new VotingViewModel(); votingViewModel.voterView = voterVM; if (votingViewModel.GetElectionDate() != null) { int ids = Convert.ToInt32(id); var v = db.Voters.Where(x => x.VoterID == ids).FirstOrDefault(); if (v != null) { //Gets the Election and increases the total votes by 1 Election getdateElection = votingViewModel.GetElectionDate(); ProvincialResult pr = new ProvincialResult(); pr.PartyID = Convert.ToInt32(PartyID); pr.ElectionID = getdateElection.ElectionID; pr.ProvincialResultsTotalVotes = 1; pr.ProvinceID = Convert.ToInt32(provinceID); v.VoteProvinceStatus = true; db.ProvincialResults.Add(pr); db.SaveChanges(); TempData["success"] = "You have successfully voted for a Provincial Government!"; return(RedirectToAction("VoterHomePage", new { VoterGUID = votingViewModel.voterView.voter.GUID, id = votingViewModel.voterView.voter.VoterID })); } else { TempData["message"] = "An Error Occured Please Try Again!"; return(RedirectToAction("VoteProvincial", new { VoterGUID = votingViewModel.voterView.voter.GUID, id = votingViewModel.voterView.voter.VoterID })); } } else { TempData["message"] = "An Error Occured Please Try Again!"; return(RedirectToAction("VoteProvincial", new { VoterGUID = votingViewModel.voterView.voter.GUID, id = votingViewModel.voterView.voter.VoterID })); } } else { TempData["message"] = "An Error Occured Please Try Again"; return(RedirectToAction("VoteProvincial", new { VoterGUID = VoterGUID, id = id })); } } else { TempData["message"] = "An Error Occured Please try again!"; return(RedirectToAction("VoteProvincial", new { VoterGUID = VoterGUID, id = id })); } }
public ActionResult ChangePasswordVoter(string VoterGUID, string id) { ViewBag.message = TempData["message"]; if (VoterGUID != null) { VoterVM voterVM = new VoterVM(); if (voterVM.IsLogedIn(db, VoterGUID)) { voterVM.RefreshGUID(db); int test = Convert.ToInt32(id); Voter v = db.Voters.Where(x => x.VoterID == test).FirstOrDefault(); if (v != null) { var searchforAnswer = v.SecurityQuestionID; if (searchforAnswer != null) { var FoundAnswer = db.SecurityQuestions.Where(y => y.SecurityQuestionID == searchforAnswer).FirstOrDefault(); if (FoundAnswer != null) { registerVoter.voterView = voterVM; registerVoter.VoterList = db.Voters.ToList(); TempData["voterVM"] = voterVM; ViewBag.Answer = FoundAnswer.SecurityQuestion1; return(View(v)); } else { TempData["message"] = "The Security Question was not found"; return(RedirectToAction("VoterHomePage", new { VoterGUID = registerVoter.voterView.voter.GUID })); } } else { TempData["message"] = "The Security Question was not found"; return(RedirectToAction("VoterHomePage", new { VoterGUID = registerVoter.voterView.voter.GUID })); } } else { TempData["message"] = "Your Information was not found!"; return(RedirectToAction("VoterHomePage", new { VoterGUID = registerVoter.voterView.voter.GUID })); } } } else { TempData["message"] = "An Error Has Occured!"; return(RedirectToAction("VoterHomePage", new { VoterGUID = registerVoter.voterView.voter.GUID })); } return(View()); }
public ActionResult VoteProvincial(string VoterGUID, string id) { VotingViewModel votingViewModel = new VotingViewModel(); if (votingViewModel.GetElectionDate() != null) { if (VoterGUID != null) { VoterVM voterVM = new VoterVM(); if (voterVM.IsLogedIn(db, VoterGUID) && voterVM.voter.VoteProvinceStatus == false) { voterVM.RefreshGUID(db); int ids = Convert.ToInt32(id); votingViewModel.voterView = voterVM; var v = db.Voters.Where(l => l.VoterID == ids).FirstOrDefault(); if (v != null) { votingViewModel.listcandidate = db.Candidates.Include(y => y.Party).Include(k => k.Party.PartyImage).Where(x => x.ProvinceID == v.ProvinceID && x.CandidatePosition_ID != 1).ToList(); return(View(votingViewModel)); } else { TempData["message"] = "You have already voted!"; return(RedirectToAction("VoterHomePage", new { VoterGUID = votingViewModel.voterView.voter.GUID })); } } else { TempData["message"] = "You have already voted!"; return(RedirectToAction("VoterHomePage", new { VoterGUID = VoterGUID })); } } else { TempData["message"] = "An Error Occured Please try again"; return(RedirectToAction("VoterHomePage", new { VoterGUID = VoterGUID })); } } else { TempData["message"] = "You can only vote on the set election date"; return(RedirectToAction("VoterHomePage", new { VoterGUID = VoterGUID })); } }
public ActionResult VoterHomePage(string VoterGUID) { if (VoterGUID != null) { VoterVM voterVM = new VoterVM(); if (voterVM.IsLogedIn(db, VoterGUID)) { voterVM.RefreshGUID(db); RegisterVoterVM registerVoterVM = new RegisterVoterVM(); registerVoterVM.voterView = voterVM; registerVoterVM.VoterList = db.Voters.ToList(); ViewBag.message = TempData["message"]; ViewBag.success = TempData["success"]; return(View(registerVoterVM)); } else { TempData["message"] = "An Error Occured Please Login Again"; return(RedirectToAction("VoterLogin")); } } else { VoterVM voterVM = TempData["voterVM"] as VoterVM; if (voterVM.IsLogedIn(db)) { voterVM.RefreshGUID(db); RegisterVoterVM registerVoterVM = new RegisterVoterVM(); registerVoterVM.voterView = voterVM; registerVoterVM.VoterList = db.Voters.ToList(); ViewBag.message = TempData["message"]; ViewBag.success = TempData["success"]; return(View(registerVoterVM)); } else { TempData["message"] = "An Error Occured Please Login Again"; return(RedirectToAction("VoterLogin")); } } TempData["message"] = "An Error Occured Please Login Again"; return(RedirectToAction("VoterLogin")); }
public ActionResult VoteParty(string VoterGUID, string id) { VotingViewModel votingViewModel = new VotingViewModel(); if (votingViewModel.GetElectionDate() != null) { if (VoterGUID != null) { VoterVM voterVM = new VoterVM(); if (voterVM.IsLogedIn(db, VoterGUID) && voterVM.voter.VotePartyStatus == false) { voterVM.RefreshGUID(db); votingViewModel.voterView = voterVM; votingViewModel.listcandidate = db.Candidates.Include(y => y.Party).Include(j => j.Party.PartyImage).Where(x => x.CandidatePosition_ID == 1).ToList(); votingViewModel.partiesImages = db.PartyImages.ToList(); ViewBag.message = TempData["message"]; ViewBag.success = TempData["success"]; return(View(votingViewModel)); } else { TempData["message"] = "You have already voted!"; return(RedirectToAction("VoterHomePage", "Voter", new { VoterGUID = VoterGUID })); } } else { TempData["message"] = "An Error Occured Please try again"; return(RedirectToAction("VoterHomePage", "Voter", new { VoterGUID = VoterGUID })); } } else { TempData["message"] = "You can only vote on the set election date"; return(RedirectToAction("VoterHomePage", new { VoterGUID = VoterGUID })); } }