// GET: Detail public ActionResult Details(String Id) { VoterDAL voterData = new VoterDAL(connectionString); Voter voter = voterData.GetVoterById(Id); return(View("Details", voter)); }
// GET: Lookup public ActionResult Lookup(string LastName) { VoterDAL voterData = new VoterDAL(connectionString); List <Voter> voters = voterData.GetVotersByLastName(LastName); if (voters.Count == 0) { //return to index ViewBag.InformationMessage = "No records found."; return(View("Index")); } else if (voters.Count == 1) { //first and only Voter voter = voters.First(); return(View("Details", voter)); } else { // send the list return(View("List", voters)); } return(View()); }
public void Excel() { VoterDAL DAL = new VoterDAL(); var model = DAL.getvoters(); Export export = new Export(); export.ToExcel(Response, model); }
public ActionResult Edit(voterModel v) { VoterDAL DAL = new VoterDAL(); List <voterModel> Voters = new List <voterModel>(); DAL.UpdateVoter(v); return(RedirectToAction("Index", "Voter")); }
// GET: Voter public ActionResult Index() { VoterDAL DAL = new VoterDAL(); List <voterModel> voters = new List <voterModel>(); voters = DAL.GetallVoter(); return(View(voters)); }
// GET: /Voter/Lookup public ActionResult Lookup() { string streetName = Request.Params["street"]; if (streetName.IsNullOrWhiteSpace()) { return(View("Query")); } List <VoterModel> votersList = new VoterDAL().getVoterByStreet(streetName); return(View("Lookup", votersList)); }
public ActionResult Edit(string id) { VoterDAL DAL = new VoterDAL(); List <voterModel> voters = new List <voterModel>(); voters = DAL.GetvoterbyID(id); voterModel v = new voterModel(); foreach (var k in voters) { v.ID = k.ID; v.voter_id = k.voter_id; v.lastname = k.lastname; v.firstname = k.firstname; v.middlename = k.middlename; v.WardId = k.WardId; v.AreaId = k.AreaId; } return(View(v)); }
public ActionResult Delete(string id) { VoterDAL DAL = new VoterDAL(); List <voterModel> voters = new List <voterModel>(); voters = DAL.GetvoterbyID(id); voterModel v = new voterModel(); foreach (var k in voters) { v.ID = k.ID; v.voter_id = k.voter_id; v.lastname = k.lastname; v.firstname = k.firstname; v.middlename = k.middlename; v.WardId = k.WardId; v.AreaId = k.AreaId; } DAL.DeleteVoter(v); return(RedirectToAction("Index", "Voter")); }
public ActionResult AddVoter(voterModel voter) { if (ModelState.IsValid) { VoterDAL DAL = new VoterDAL(); List <voterModel> voters = new List <voterModel>(); voterModel vt1 = new voterModel(); vt1 = DAL.GetallVoterWithDeleted().Find(x => x.voter_id == voter.voter_id); List <voterModel> VoterCheck = DAL.GetvoterbyID(voter.voter_id); if (vt1 == null) { DAL.Addvoter(voter); return(RedirectToAction("Index", "Voter")); } else { ModelState.AddModelError("", "VoterID Is Already Exists "); return(View(voter)); } } return(View(voter)); }