public ActionResult Create(Contacts contacts) { if (ModelState.IsValid) { db.Contacts.Add(contacts); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.UserId = new SelectList(db.UserData, "UserId", "Name", contacts.UserId); return View(contacts); }
public ActionResult Edit(Contacts contacts) { if (ModelState.IsValid) { db.Entry(contacts).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.UserId = new SelectList(db.UserData, "UserId", "Name", contacts.UserId); return View(contacts); }