Example #1
0
        public ActionResult Create(Filme filme)
        {
            if (ModelState.IsValid)
            {
                db.filmes.Add(filme);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.CategoriaID = new SelectList(db.categorias, "CategoriaID", "Designacao", filme.CategoriaID);
            ViewBag.ActorID = new SelectList(db.actores, "ActorID", "Nome", filme.ActorID);
            ViewBag.AutorID = new SelectList(db.autores, "AutorID", "Nome", filme.AutorID);
            return View(filme);
        }
Example #2
0
 public ActionResult Edit(Filme filme)
 {
     if (ModelState.IsValid)
     {
         db.Entry(filme).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.CategoriaID = new SelectList(db.categorias, "CategoriaID", "Designacao", filme.CategoriaID);
     ViewBag.ActorID = new SelectList(db.actores, "ActorID", "Nome", filme.ActorID);
     ViewBag.AutorID = new SelectList(db.autores, "AutorID", "Nome", filme.AutorID);
     return View(filme);
 }