Пример #1
0
        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);
        }
Пример #2
0
 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);
 }