public ActionResult Create(Aluguer aluguer) { if (ModelState.IsValid) { db.Aluguer.Add(aluguer); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.FilmeID = new SelectList(db.Filmes, "FilmeID", "Titulo", aluguer.FilmeID); ViewBag.UtenteID = new SelectList(db.Utentes, "UtenteID", "Nome", aluguer.UtenteID); return View(aluguer); }
public ActionResult Edit(Aluguer aluguer) { if (ModelState.IsValid) { db.Entry(aluguer).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.FilmeID = new SelectList(db.Filmes, "FilmeID", "Titulo", aluguer.FilmeID); ViewBag.UtenteID = new SelectList(db.Utentes, "UtenteID", "Nome", aluguer.UtenteID); return View(aluguer); }