private void updateButton_Click(object sender, RoutedEventArgs e) { try { if (iSBNTextBox.Text == "") { throw new Exception("Please enter the ISBN of the book you would like to update."); } BookSearch search = new BookSearch(books, people, iSBNTextBox.Text.Trim()); search.ISBNSearch(); if (search.FoundBooks.Count == 0) { throw new Exception("No book was found with that ISBN."); } //The found book will now be placed into a bookUpdater object for the updating process BookUpdater updater = new BookUpdater(books, people, logs, search.FoundBooks[0]); //Load the bookUpdatePage Reset(); this.NavigationService.Navigate(new UpdateBookPage(updater)); } catch (Exception ex) { errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex); } }
public void TestSearchForOnlyISBN() { //Arrange PersonBLLCollection people = CreatePersonBLLCollection(); BookBLLCollection books = CreateBookCollection(); string query = "4004"; //Act BookSearch search = new BookSearch(books, people, query); search.ISBNSearch(); //Assert Assert.AreEqual(1, search.FoundBooks.Count); }
private void removeButton_Click(object sender, RoutedEventArgs e) { try { BookSearch search = new BookSearch(books, people, iSBNTextBox.Text.Trim()); search.ISBNSearch(); if (search.FoundBooks.Count == 0) { throw new Exception("No book was found matching that ISBN"); } BookUpdater updater = new BookUpdater(books, people, logs, search.FoundBooks[0], true); Reset(); this.NavigationService.Navigate(new AddSubtractCopiesPage(updater)); } catch (Exception ex) { errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex); } }
private void addButton_Click(object sender, RoutedEventArgs e) { try { //Searches for a book by ISBN, if one is found then additional copies will be added to it. //If no book is found then a new book will be created. if (iSBNTextBox.Text == "") { throw new Exception("Please enter an ISBN"); } BookSearch search = new BookSearch(books, people, iSBNTextBox.Text.Trim()); search.ISBNSearch(); if (search.FoundBooks.Count == 0) { //A new book is being added to the database //Create the bookBuilder that will make the bookBLL BookBuilder builder = new BookBuilder(books, people, iSBNTextBox.Text.Trim()); //Request author information RequestAuthorWindow dialog1 = new RequestAuthorWindow(builder); if (dialog1.ShowDialog() == true) { //Check if a new author is being created, is so ask for bio if (builder.AuthorBuilder != null) { RequestAuthorBio dialog2 = new RequestAuthorBio(builder); dialog2.ShowDialog(); } Reset(); this.NavigationService.Navigate(new NewBookKnownAuthor(builder)); } } else { BookUpdater updater = new BookUpdater(books, people, logs, search.FoundBooks[0]); Reset(); this.NavigationService.Navigate(new AddSubtractCopiesPage(updater)); } } catch (Exception ex) { errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex); } }