public void TestAddEvent() { books.addBookEvent += testLstner; Book book = new Book("Name", "Catagory", "ReadingStatus", new List <string>()); books.AddBook(book); Assert.AreEqual("Name", str); }
public void RecommendBook(string title1, string author1, string genreOfBook1, string titleOfBook2, string authorOfBook2, string typeofBook2) { if (Books.BooksAndAuthors.Find(x => x.Value == title1).Value == null) { Books.AddBook(title1, author1, genreOfBook1); } if (Books.BooksAndAuthors.Find(x => x.Value == titleOfBook2).Value == null) { Books.AddBook(titleOfBook2, authorOfBook2, typeofBook2); } RecommendedBooks.Add(new KeyValuePair <string, string>(title1, titleOfBook2)); }
/// <summary> /// Checking books's input and sending it to the database /// </summary> /// <returns>True if book sent to DB, otherwise false</returns> private bool AddItemBook() { BookAddViewModel viewmodel = (BookAddViewModel)DataContext; Book book = viewmodel.MyBook; if (string.IsNullOrEmpty(book.Title)) { MessageBox.Show("Title cannnot be empty."); return(false); } if (book.Author_AtBook == null) { MessageBox.Show("Author must be added."); return(false); } if (book.Genre_AtBook == null) { MessageBox.Show("Genre must be added."); return(false); } try { int id = MSAConnectionDB.SaveBookToDB(book); book.BookId = id; Books.AddBook(book); Genres.AddBookToGenre(book, book.Genre_AtBook); Authors.AddBookToAuthor(book, book.Author_AtBook); ActivateMainWindow(); } catch (Exception e) { MessageBox.Show(e.Message); } return(true); }