Exemplo n.º 1
0
        PersonBLLCollection CreatePersonBLLCollection()
        {
            PersonBLLCollection people  = new PersonBLLCollection();
            AuthorBLL           author1 = new AuthorBLL()
            {
                ID        = 1,
                FirstName = "Sam",
                LastName  = "Jacobs"
            };
            AuthorBLL author2 = new AuthorBLL()
            {
                ID        = 2,
                FirstName = "Fran",
                LastName  = "Heathwood"
            };
            AuthorBLL author3 = new AuthorBLL()
            {
                ID        = 3,
                FirstName = "Tom",
                LastName  = "Marrows"
            };
            AuthorBLL author4 = new AuthorBLL()
            {
                ID        = 4,
                FirstName = "Karen",
                LastName  = "Flint"
            };

            people.Add(author1);
            people.Add(author2);
            people.Add(author3);
            people.Add(author4);

            return(people);
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                //Set up screen
                ResetFields();
                usernameLabel.Content = user.LoginMessage();
                patronLabel.Content   = "Patron: " + patron.ToString();

                //Set fields
                books  = ((MainWindow)App.Current.MainWindow).Books;
                logs   = ((MainWindow)App.Current.MainWindow).Logs;
                people = ((MainWindow)App.Current.MainWindow).People;


                //Get list of checked out logs and the list of overdue logs
                SetListBox();


                //Check for good standing, report if bad
                goodStanding = IsInGoodStanding();
            }
            catch (Exception ex)
            {
                errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex);
            }
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                bookDetailTextBox.Text = "";
                books  = ((MainWindow)App.Current.MainWindow).Books;
                logs   = ((MainWindow)App.Current.MainWindow).Logs;
                people = ((MainWindow)App.Current.MainWindow).People;
                //If in patron mode (no user is logged in) remove books with no copies
                if (user == null)
                {
                    foundBooksFiltered = new List <BookBLL>();
                    foreach (BookBLL b in searchResults.FoundBooks)
                    {
                        if (b.NumberOfCopies > 0)
                        {
                            foundBooksFiltered.Add(b);
                        }
                    }
                }
                else
                {
                    //Librarian Mode
                    foundBooksFiltered = searchResults.FoundBooks;
                }
                //Reports if no books were found.
                if (foundBooksFiltered.Count == 0)
                {
                    resultsLabel.Content = $"No books matched query: {searchResults.QueryTerms}";
                }
                else
                {
                    //Populates the listBox with the found books.
                    string resultsLabelString = $"{foundBooksFiltered.Count} book";
                    if (foundBooksFiltered.Count == 0 || foundBooksFiltered.Count > 1)
                    {
                        resultsLabelString += "s";
                    }
                    resultsLabelString += $" matched query: {searchResults.QueryTerms}";

                    resultsLabel.Content = resultsLabelString;
                    listboxBookstrings   = new List <string>();
                    foreach (BookBLL b in foundBooksFiltered)
                    {
                        string infoString = AvailabilityBuilder(b);
                        listboxBookstrings.Add(infoString);
                    }
                    resultsListBox.DataContext = listboxBookstrings;
                }
            }
            catch (Exception ex)
            {
                errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex);
            }
        }
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         people = ((MainWindow)App.Current.MainWindow).People;
     }
     catch (Exception ex)
     {
         errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex);
     }
 }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         errorLabel.Content = "";
         usernameTextBox.Focus();
         people = ((MainWindow)App.Current.MainWindow).People;
     }
     catch (Exception ex)
     {
         errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex);
     }
 }
Exemplo n.º 6
0
        public void TestSearchAllFieldsForISBN()
        {
            //Arrange
            PersonBLLCollection people = CreatePersonBLLCollection();
            BookBLLCollection   books  = CreateBookCollection();

            string query = "3003";
            //Act
            BookSearch search = new BookSearch(books, people, query);

            search.SearchAllFields();

            //Assert
            Assert.AreEqual(1, search.FoundBooks.Count);
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                //Sets up the collection references and sets the page
                books  = ((MainWindow)App.Current.MainWindow).Books;
                logs   = ((MainWindow)App.Current.MainWindow).Logs;
                people = ((MainWindow)App.Current.MainWindow).People;

                Reset();
            }
            catch (Exception ex)
            {
                errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex);
            }
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        public void TestSearchForWordNotThere()
        {
            //Arrange
            PersonBLLCollection people = CreatePersonBLLCollection();
            BookBLLCollection   books  = CreateBookCollection();

            string query = "Zebra";

            //Act
            BookSearch search = new BookSearch(books, people, query);

            search.SearchAllFields();

            //Assert
            Assert.AreEqual(0, search.FoundBooks.Count);
        }
Exemplo n.º 10
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         ResetFields();
         greetingLabel.Content = "Greetings! You may search the catalog for books using key terms\nfrom the title, ISBN, subject, or author's name.";
         searchTextBox.Focus();
         books  = ((MainWindow)App.Current.MainWindow).Books;
         logs   = ((MainWindow)App.Current.MainWindow).Logs;
         people = ((MainWindow)App.Current.MainWindow).People;
     }
     catch (Exception ex)
     {
         errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex);
     }
 }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                ResetFields();
                books  = ((MainWindow)App.Current.MainWindow).Books;
                logs   = ((MainWindow)App.Current.MainWindow).Logs;
                people = ((MainWindow)App.Current.MainWindow).People;

                librarianMenuLists = new LibrarianMenuLists(people, books, logs);

                usernameLabel.Content = User.LoginMessage();
            }
            catch (Exception ex)
            {
                errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex);
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //If no database exists this will create it with Code First, otherwise this does nothing.
            CreateCodeFirstDatabase.CreateAndInitializeDatabase();

            //The datamanger will handle locating and creating the XML files when the program ends.
            dataManager = new DataManager();

            //Populate the three collections (books, people, checkoutlogs)
            Books = new BookBLLCollection();
            Books.PopulateBooks();
            People = new PersonBLLCollection();
            People.PopulatePeople();
            Logs = new CheckOutLogBLLCollection();
            Logs.PopulateLogs();

            Main.Content = new StartingPage();
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                errorLabel.Content = "";
                books  = ((MainWindow)App.Current.MainWindow).Books;
                logs   = ((MainWindow)App.Current.MainWindow).Logs;
                people = ((MainWindow)App.Current.MainWindow).People;
                if (updater.RemoveCopies == true)
                {
                    instructionsLabel.Content = "You may remove copies from the selected book.";
                }

                GetBookLongDetails();
            }
            catch (Exception ex)
            {
                errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex);
            }
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                errorLabel.Content = "";
                books  = ((MainWindow)App.Current.MainWindow).Books;
                people = ((MainWindow)App.Current.MainWindow).People;

                //Set the author detail box

                if (builder.AuthorBuilder == null)
                {
                    //There is already in author, load the text with the info
                    List <PersonBLL> personBLLs = (from x in people
                                                   where x.ID == builder.Book.AuthorID
                                                   select x).ToList();
                    foreach (PersonBLL p in personBLLs)
                    {
                        if (p is AuthorBLL a)
                        {
                            authorDetailTextBox.Text = a.ToString();
                        }
                    }
                }
                else
                {
                    //A new author will be created at the end of the process, just report their first and last name
                    string output = $"{builder.AuthorBuilder.Author.FirstName} {builder.AuthorBuilder.Author.LastName}";
                    authorDetailTextBox.Text = output;
                }

                //Set the given ISBN
                givenISBN.Content = builder.Book.ISBN;
            }
            catch (Exception ex)
            {
                errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex);
            }
        }