Ejemplo n.º 1
0
        public ActionResult Create(Candidate candidate)
        {
            if (ModelState.IsValid)
            {
                context.Candidates.Add(candidate);
                context.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.PossibleDistricts = context.Districts;
            return View(candidate);
        }
Ejemplo n.º 2
0
 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);
 }