Exemple #1
0
 public List <Model.Libro> ListarLibro()
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             return(context.LibroSet.Include("Autor").Include("Editorial").Include("Clasificacion").Include("Genero").ToList());
         }
         catch (Exception e)
         {
             throw new Exception("Lista sin elementos ", e);
         }
     }
 }
Exemple #2
0
 public List <Model.Genero> ListarGenero()
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             return(context.GeneroSet.ToList());
         }
         catch (Exception e)
         {
             throw new Exception("Lista sin elementos ", e);
         }
     }
 }
Exemple #3
0
 public List <Model.Prestamo> ListarPrestamos()
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             return(context.PrestamoSet.Include("Usuario").Include("Libro").ToList());
         }
         catch (Exception e)
         {
             throw new Exception("Lista sin elementos ", e);
         }
     }
 }
Exemple #4
0
 public void InsertarUsuario(Model.Usuario usuario)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             context.UsuarioSet.Add(usuario);
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido insertar el usuario ", e);
         }
     }
 }
Exemple #5
0
 public void InsertarClasificacion(Model.Clasificacion clasificacion)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             context.ClasificacionSet.Add(clasificacion);
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido insertar la clasificación ", e);
         }
     }
 }
Exemple #6
0
 public void InsertarAutor(Model.Autor autor)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             context.AutorSet.Add(autor);
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido insertar el autor ", e);
         }
     }
 }
Exemple #7
0
 public void InsertarEditorial(Model.Editorial editorial)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             context.EditorialSet.Add(editorial);
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido insertar la editorial ", e);
         }
     }
 }
Exemple #8
0
 public void InsertarPrestamo(Model.Prestamo prestamo)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             context.PrestamoSet.Add(prestamo);
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido insertar el préstamo ", e);
         }
     }
 }
Exemple #9
0
 public void InsertarGenero(Model.Genero genero)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             context.GeneroSet.Add(genero);
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido insertar el género ", e);
         }
     }
 }
Exemple #10
0
 public void BorrarPrestamo(int prestamoID)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             var pres = context.PrestamoSet.FirstOrDefault(x => x.PrestamoId == prestamoID);
             context.Entry(pres).State = System.Data.Entity.EntityState.Deleted;
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido borrar el préstamo ", e);
         }
     }
 }
Exemple #11
0
 public void BorrarAutor(int AutorId)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             var aut = context.AutorSet.FirstOrDefault(x => x.AutorId == AutorId);
             context.Entry(aut).State = System.Data.Entity.EntityState.Deleted;
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido borrar el autor ", e);
         }
     }
 }
Exemple #12
0
 public void BorrarGenero(int GeneroID)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             var g = context.GeneroSet.FirstOrDefault(x => x.GeneroId == GeneroID);
             context.Entry(g).State = System.Data.Entity.EntityState.Deleted;
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido borrar el género ", e);
         }
     }
 }
Exemple #13
0
 public void BorrarClasificacion(int clasificacionId)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             var cla = context.ClasificacionSet.FirstOrDefault(x => x.ClasificacionId == clasificacionId);
             context.Entry(cla).State = System.Data.Entity.EntityState.Deleted;
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido borrar la clasificación ", e);
         }
     }
 }
Exemple #14
0
 public void BorrarEditorial(int EditorialID)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             var edi = context.EditorialSet.FirstOrDefault(x => x.EditorialId == EditorialID);
             context.Entry(edi).State = System.Data.Entity.EntityState.Deleted;
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido borrar la editorial ", e);
         }
     }
 }
Exemple #15
0
 public void BorrarUsuario(String UsuarioDNI)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             var usu = context.UsuarioSet.FirstOrDefault(x => x.DNI.Equals(UsuarioDNI));
             context.Entry(usu).State = System.Data.Entity.EntityState.Deleted;
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido borrar el usuario ", e);
         }
     }
 }
Exemple #16
0
 public void ActualizarPrestamo(Model.Prestamo prestamo)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             var pres = context.PrestamoSet.FirstOrDefault(x => x.PrestamoId == prestamo.PrestamoId);
             context.Entry(pres).State = System.Data.Entity.EntityState.Modified;
             context.Entry(pres).CurrentValues.SetValues(prestamo);
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido actualizar el préstamo ", e);
         }
     }
 }
Exemple #17
0
 public void ActualizarGenero(Model.Genero genero)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             var g = context.GeneroSet.FirstOrDefault(x => x.GeneroId == genero.GeneroId);
             context.Entry(g).State = System.Data.Entity.EntityState.Modified;
             context.Entry(g).CurrentValues.SetValues(genero);
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido actualizar el género ", e);
         }
     }
 }
Exemple #18
0
 public void ActualizarUsuario(Model.Usuario usuario)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             var usu = context.UsuarioSet.FirstOrDefault(x => x.DNI == usuario.DNI);
             context.Entry(usu).State = System.Data.Entity.EntityState.Modified;
             context.Entry(usu).CurrentValues.SetValues(usuario);
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido actualizar el usuario ", e);
         }
     }
 }
Exemple #19
0
 public void ActualizarClasificacion(Model.Clasificacion clasificacion)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             var cla = context.ClasificacionSet.FirstOrDefault(x => x.ClasificacionId == clasificacion.ClasificacionId);
             context.Entry(cla).State = System.Data.Entity.EntityState.Modified;
             context.Entry(cla).CurrentValues.SetValues(clasificacion);
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido acualizar la clasificación ", e);
         }
     }
 }
Exemple #20
0
 public void ActualizarAutor(Model.Autor autor)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             var aut = context.AutorSet.FirstOrDefault(x => x.AutorId == autor.AutorId);
             context.Entry(aut).State = System.Data.Entity.EntityState.Modified;
             context.Entry(aut).CurrentValues.SetValues(autor);
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido actualizar el autor ", e);
         }
     }
 }
Exemple #21
0
 public void ActualizarEditorial(Model.Editorial editorial)
 {
     using (var context = new Model.BibliotecaContextContainer())
     {
         try
         {
             var edi = context.EditorialSet.FirstOrDefault(x => x.EditorialId == editorial.EditorialId);
             context.Entry(edi).State = System.Data.Entity.EntityState.Modified;
             context.Entry(edi).CurrentValues.SetValues(editorial);
             context.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido actualizar la editorial ", e);
         }
     }
 }