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); }
public bool AddNewBook(Book book) { database.books.Add(DBToLibrary.LibraryToBook(book)); database.SaveChanges(); return(true); }