public ActionResult Create(Phone phone) { if (ModelState.IsValid) { db.Phones.Add(phone); db.SaveChanges(); return RedirectToAction("Details","Person",new{id = phone.PersonID}); } ViewBag.PersonID = new SelectList(db.People, "PersonID", "First", phone.PersonID); ViewBag.PhoneTypeID = new SelectList(db.PhoneTypes, "PhoneTypeID", "Type", phone.PhoneTypeID); return View(phone); }
public ActionResult Edit(Phone phone) { if (ModelState.IsValid) { db.Entry(phone).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Details", "Person", new { id = phone.PersonID }); } ViewBag.PersonID = new SelectList(db.People, "PersonID", "First", phone.PersonID); ViewBag.PhoneTypeID = new SelectList(db.PhoneTypes, "PhoneTypeID", "Type", phone.PhoneTypeID); return View(phone); }