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

            db.tbl_Libro.Remove(tbl_Libro);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "idLibro,Titulo,Autor,ISBN,Fecha_publicacion,Numero_de_Ejemplares,idCategoria")] tbl_Libro tbl_Libro)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_Libro).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idCategoria = new SelectList(db.tblCategoria, "idCategoria", "nombre", tbl_Libro.idCategoria);
     return(View(tbl_Libro));
 }
        // GET: tbl_Libro/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_Libro tbl_Libro = db.tbl_Libro.Find(id);

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

            if (tbl_Libro == null)
            {
                return(HttpNotFound());
            }
            ViewBag.idCategoria = new SelectList(db.tblCategoria, "idCategoria", "nombre", tbl_Libro.idCategoria);
            return(View(tbl_Libro));
        }
Beispiel #5
0
 public static void Create(tbl_Libro a)
 {
     using (dbBibliotecaEntities db = new dbBibliotecaEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.tbl_Libro.Add(a);
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
Beispiel #6
0
 public static void Delete(int? id)
 {
     using (dbBibliotecaEntities db = new dbBibliotecaEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 tbl_Libro tbl_Libro = db.tbl_Libro.Find(id);
                 db.Entry(tbl_Libro).State = System.Data.Entity.EntityState.Deleted;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
Beispiel #7
0
 public static void Update(tbl_Libro tbl_Libro)
 {
     using (dbBibliotecaEntities db = new dbBibliotecaEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.tbl_Libro.Attach(tbl_Libro);
                 db.Entry(tbl_Libro).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }