public Parent(ParentViewModel child) { PhoneNumber = child.PhoneNumber; FullName = child.FullName; Id = child.Id; Address = child.Address; WorkPlace = child.WorkPlace; Relatives = child.Relatives; }
public ActionResult AddParents(ParentViewModel parent) { if (ModelState.IsValid) { Parent worker = new Parent(parent); Parent b = db.Parents.Find(parent.Id); if (b != null) { worker.Id = parent.Id; UpdateModel(b); db.SaveChanges(); } else { Child c = db.Children.Find(parent.ChildId); List<Child> s = new List<Child> { c }; worker.Childs = s; db.Parents.Add(worker); db.SaveChanges(); } return PartialView("Kostil"); } return PartialView(parent); }
public PartialViewResult AddParents() { ParentViewModel child = new ParentViewModel(); child.Id = -1; return PartialView("AddParents", child); }