public ActionResult Edit(Exemplar exemplar) { if (ModelState.IsValid) { exemplar.ConfigurarParaSalvar(); db.Entry(exemplar).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.editoraId = new SelectList(db.Fornecedor, "id", "nome"); ViewBag.idiomaId = new SelectList(db.Idioma, "id", "nome", exemplar.idiomaId); ViewBag.sessaoId = new SelectList(db.Sessao, "id", "nome", exemplar.sessaoId); return(View(exemplar)); }
public ActionResult Create(Exemplar exemplar) { if (ModelState.IsValid) { if (VerificaJaExiste(exemplar)) { ViewBag.Erro = "Ja existe um registro com o ISBN informado!"; return(View(exemplar)); } exemplar.ConfigurarParaSalvar(); db.Item.Add(exemplar); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.editoraId = new SelectList(db.Fornecedor, "id", "nome"); ViewBag.idiomaId = new SelectList(db.Idioma, "id", "nome", exemplar.idiomaId); ViewBag.sessaoId = new SelectList(db.Sessao, "id", "nome", exemplar.sessaoId); return(View(exemplar)); }