public bool RegistreBook(string name)
 {
     using (var db = new BBDD_BibliotecaEntities())
     {
         try
         {
             db.Libros.Add(new Libros {Titulo = name});
             db.SaveChanges();
             return true;
         }
         catch (Exception e)
         {
             throw new Exception(e.Message);
         }
     }
 }
 public bool ReturnBook(int id)
 {
     using (var db = new BBDD_BibliotecaEntities())
     {
         try
         {
             var prestamo = db.Prestamos.First(x => x.LibroId == id);
             db.Prestamos.Remove(prestamo);
             db.SaveChanges();
             return true;
         }
         catch (Exception e)
         {
             throw new Exception(e.Message);
         }
     }
 }
        public bool LoanBook(int libroId, int usuarioId)
        {
            using (var db = new BBDD_BibliotecaEntities())
            {
                try
                {
                    db.Prestamos.Add(new Prestamos
                    {
                        LibroId = libroId,
                        UsuarioId = usuarioId,
                        FechaPrestamo = DateTime.Now.Date
                    });

                    db.SaveChanges();
                    return true;
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
        }
 public void PayFine(int usuarioId)
 {
     using (var db = new BBDD_BibliotecaEntities())
     {
         try
         {
             var multa = db.Multas.First(x => x.UsuarioId == usuarioId);
             db.Multas.Remove(multa);
             db.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception(e.Message);
         }
     }
 }
 public bool AddFine(int usuarioId)
 {
     using (var db = new BBDD_BibliotecaEntities())
     {
         try
         {
             db.Multas.Add(new Multas
             {
                 UsuarioId = usuarioId
             });
             db.SaveChanges();
             return true;
         }
         catch (Exception e)
         {
             throw new Exception(e.Message);
         }
     }
 }
        public bool CrearUsuario(string nombreUsuario)
        {
            using (var db = new BBDD_BibliotecaEntities())
            {
                try
                {
                    db.Usuarios.Add(new Usuarios
                    {
                        Nombre = nombreUsuario
                    });

                    db.SaveChanges();
                    return true;
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
        }