Exemplo n.º 1
0
        public bool EditBook(int bookId, Book newBook)
        {
            var bookToEdit = database.books.Where((book) => book.Id == bookId).First();

            if (bookToEdit == null)
            {
                return(false);
            }

            database.Entry(bookToEdit).CurrentValues.SetValues(DBToLibrary.LibraryToBook(newBook));
            database.SaveChanges();
            return(true);
        }
Exemplo n.º 2
0
        public bool EditPerson(int oldPersonId, Person newPerson)
        {
            var personToEdit = database.users.Where((person) => person.Id == oldPersonId).First();

            if (personToEdit == null)
            {
                return(false);
            }

            database.Entry(personToEdit).CurrentValues.SetValues(DBToLibrary.LibraryToUser(newPerson));
            database.SaveChanges();
            return(true);
        }
Exemplo n.º 3
0
        public Person GetPersonByNameSurnamePassword(string name, string surname, string password)
        {
            var personByData = database.users.Where((person) => person.Name.Equals(name) && person.Surname.Equals(surname) && person.Password.Equals(password)).First();

            return(DBToLibrary.UserToLibrary(personByData));
        }
Exemplo n.º 4
0
        public Person GetPersonByID(int id)
        {
            var personById = database.users.Where((person) => person.Id == id).First();

            return(DBToLibrary.UserToLibrary(personById));
        }
Exemplo n.º 5
0
 public bool AddNewPerson(Person person)
 {
     database.users.Add(DBToLibrary.LibraryToUser(person));
     database.SaveChanges();
     return(true);
 }
Exemplo n.º 6
0
        public List <Person> GetAllPersons()
        {
            var personsFromDB = database.users;

            return(DBToLibrary.UserListToLibrary(personsFromDB.ToList <DatabaseWithEntity.users>()));
        }
Exemplo n.º 7
0
        public List <Book> Find(string search)
        {
            var booksFound = database.books.Where((book) => book.Name.Contains(search) || book.Author.Contains(search));

            return(DBToLibrary.BookListToLibrary(booksFound.ToList <DatabaseWithEntity.books>()));
        }
Exemplo n.º 8
0
        public List <Book> GetReadersBooks(int readerId)
        {
            var readersBooks = database.books.Where((book) => book.IsTaken == true && book.UserId == readerId);

            return(DBToLibrary.BookListToLibrary(readersBooks.ToList <DatabaseWithEntity.books>()));
        }
Exemplo n.º 9
0
        public List <Book> GetAllBooks()
        {
            var booksFromDB = database.books;

            return(DBToLibrary.BookListToLibrary(booksFromDB.ToList <DatabaseWithEntity.books>()));
        }
Exemplo n.º 10
0
        public Book GetBookByIsbn(string isbn)
        {
            var bookByIsbn = database.books.Where((book) => book.Isbn == isbn).First();

            return(DBToLibrary.BookToLibrary(bookByIsbn));
        }
Exemplo n.º 11
0
        public Book GetBookByCode(string isbn, string code)
        {
            var bookByCode = database.books.Where((book) => book.Isbn == isbn && book.Code == code).First();

            return(DBToLibrary.BookToLibrary(bookByCode));
        }
Exemplo n.º 12
0
        public Book GetBookById(int id)
        {
            var bookById = database.books.Where((book) => book.Id == id).First();

            return(DBToLibrary.BookToLibrary(bookById));
        }
Exemplo n.º 13
0
 public bool AddNewBook(Book book)
 {
     database.books.Add(DBToLibrary.LibraryToBook(book));
     database.SaveChanges();
     return(true);
 }