public void Save(AgitatorHouseRelation 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 AddRelatedHouse(AgitatorHouseRelation obj) { if (ModelState.IsValid) { dataManager.AgitatorHouseRelations.Save(obj); return RedirectToAction("Show", new { Id = obj.AgitatorId }); } ViewBag.Houses = from h in dataManager.Houses.GetAll() select new SelectListItem { Text = h.Name, Value = h.Id.ToString() }; return View(obj); }