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