public void Save(AgitatorPrecinctRelation obj) { if (obj.Id == 0) { context.Entry(obj).State = System.Data.Entity.EntityState.Added; } else { context.Entry(obj).State = System.Data.Entity.EntityState.Modified; } context.SaveChanges(); }
public ActionResult AddRelatedPrecinct(AgitatorPrecinctRelation obj) { if (ModelState.IsValid) { dataManager.AgitatorPrecinctRelations.Save(obj); return(RedirectToAction("Show", new { Id = obj.AgitatorId })); } ViewBag.Precincts = from h in dataManager.Precincts.GetAll() select new SelectListItem { Text = h.Name, Value = h.Id.ToString() }; return(View(obj)); }