public ActionResult Create(Candidate candidate) { if (ModelState.IsValid) { context.Candidates.Add(candidate); context.SaveChanges(); return RedirectToAction("Index"); } ViewBag.PossibleDistricts = context.Districts; return View(candidate); }
public ActionResult Edit(Candidate candidate) { if (ModelState.IsValid) { context.Entry(candidate).State = EntityState.Modified; context.SaveChanges(); return RedirectToAction("Index"); } ViewBag.PossibleDistricts = context.Districts; return View(candidate); }