public ActionResult DeleteConfirmed(int id)
        {
            tblPelicula tblPelicula = db.tblPelicula.Find(id);

            db.tblPelicula.Remove(tblPelicula);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "id,nombre,estreno,categoria,duracion")] tblPelicula tblPelicula)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblPelicula).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblPelicula));
 }
        public ActionResult Create([Bind(Include = "id,nombre,estreno,categoria,duracion")] tblPelicula tblPelicula)
        {
            if (ModelState.IsValid)
            {
                db.tblPelicula.Add(tblPelicula);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tblPelicula));
        }
        // GET: Peliculas/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblPelicula tblPelicula = db.tblPelicula.Find(id);

            if (tblPelicula == null)
            {
                return(HttpNotFound());
            }
            return(View(tblPelicula));
        }
Exemplo n.º 5
0
 public static void Create(tblPelicula p)
 {
     using (dbpeliculasEntities db = new dbpeliculasEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.tblPelicula.Add(p);
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
Exemplo n.º 6
0
 public static void Delete(int?id)
 {
     using (dbpeliculasEntities db = new dbpeliculasEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 tblPelicula pelicula = db.tblPelicula.Find(id);
                 db.Entry(pelicula).State = System.Data.Entity.EntityState.Deleted;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw;
             }
         }
     }
 }
Exemplo n.º 7
0
 public static void Update(tblPelicula pelicula)
 {
     using (dbpeliculasEntities db = new dbpeliculasEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.tblPelicula.Attach(pelicula);
                 db.Entry(pelicula).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }