public ActionResult Create([Bind(Include = "Id,Name,Province")] City city) { if (ModelState.IsValid) { db.Cities.Add(city); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(city)); }
public ActionResult ApproveProvincial(List <Election> notApproved) { ElectionCatalog db = new ElectionCatalog(); var approved = from Election in notApproved where Election.isApproved == true select Election; CandidateApplication candidateApplication = null; foreach (var item in approved) { candidateApplication = new CandidateApplication(); var city = from election in db.Elections where election.ID == item.ID select election.City; candidateApplication.City = city.FirstOrDefault() as string; candidateApplication.Candidate = (string)Session["UserName"]; candidateApplication.Election_Id = item.ID; candidateApplication.Level = "Provincial"; db.CandidateApplications.Add(candidateApplication); } db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult CastVoteTo(Vote vote) { ElectionCatalog db = new ElectionCatalog(); db.Votes.Add(vote); db.SaveChanges(); return(View()); }
public ActionResult RegisterType(User user, FormCollection Form) { user.PicPath = SaveImage(user.PicPath.Substring(23, user.PicPath.Length - 23), user.UserName); ElectionCatalog db = new ElectionCatalog(); db.Users.Add(user); db.SaveChanges(); return(RedirectToAction("Index", "Login")); }
public ActionResult Approve(List <User> notApproved) { ElectionCatalog db = new ElectionCatalog(); var approved = from User in notApproved where User.isApproved == true select User; foreach (var item in approved) { db.Users.Find(item.UserName).isApproved = true; } db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Election election, string[] checkedItems) { if (Session["UserName"] == null) { return(RedirectToAction("Index", "Login")); } int maxId = db.Elections.Max(e => e.ID); election.Level = Session["Level"].ToString(); for (int i = 0; i < checkedItems.Length; i++) { maxId++; election.City = checkedItems[i]; election.ID = maxId; Election temp = new Election(election); db.Elections.Add(temp); db.SaveChanges(); } return(RedirectToAction("Index")); }