예제 #1
0
        public ActionResult Crear(Pelicula pelicula)
        {
            if (ModelState.IsValid)
            {
                db.PeliculaConjunto.Add(pelicula);
                db.SaveChanges();

                if (pelicula.Caratula != null && pelicula.Caratula.ContentLength > 0)
                {
                    var filename = "caratula_" + pelicula.Id + ".jpg";
                    var path = Path.Combine(Server.MapPath("~/Images/Caratulas"), filename);
                    pelicula.Caratula.SaveAs(path);
                }

                return RedirectToAction("Index","Home");
            }

            return View(pelicula);
        }
예제 #2
0
 public ActionResult Editar(Pelicula pelicula)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pelicula).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(pelicula);
 }