public ActionResult Edit(Play play) { if (ModelState.IsValid) { db.Entry(play).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.AuthorId = new SelectList(db.Authors, "Id", "Name", play.AuthorId); ViewBag.GenreId = new SelectList(db.Genres, "Id", "Name", play.GenreId); return View(play); }
public ActionResult Create(Play play) { if (ModelState.IsValid) { db.Plays.Add(play); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.AuthorId = new SelectList(db.Authors, "Id", "Name", play.AuthorId); ViewBag.GenreId = new SelectList(db.Genres, "Id", "Name", play.GenreId); return View(play); }