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); } } }
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); } } }
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); } } }
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); } } }
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); } } }
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); } } }
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); } } }
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); } } }
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); } } }
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); } } }
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); } } }
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); } } }
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); } } }
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); } } }
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); } } }
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); } } }
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); } } }
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); } } }
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); } } }
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); } } }
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); } } }