/// <summary>
        /// Returns a list of strings to display information about overdue books and their cardholders.
        /// </summary>
        /// <returns></returns>
        public List <string> GetOverdueBookInformation()
        {
            List <CheckOutLogBLL> overdues   = logs.GetOverdueLogs();
            List <string>         outputList = new List <string>();

            if (overdues.Count == 0)
            {
                outputList.Add("There are no records of overdue books.");
            }
            else
            {
                //I have logs, now I need book and cardholder
                overdues.Sort();
                foreach (CheckOutLogBLL l in overdues)
                {
                    BookBLL book = (from b in books
                                    where b.BookID == l.BookID
                                    select b).FirstOrDefault();
                    CardholderBLL cardholder = (CardholderBLL)(from c in people
                                                               where c is CardholderBLL
                                                               where c.ID == l.CardholderID
                                                               select c).FirstOrDefault();
                    //Build the string and add it to the listBox
                    string o = $"{book.ToString()} {l.ToString()} Cardholder: {cardholder.ToString()} ";
                    outputList.Add(o);
                }
            }
            return(outputList);
        }
 public BookUpdater(BookBLLCollection Books, PersonBLLCollection People, CheckOutLogBLLCollection Logs, BookBLL targetBook)
 {
     books  = Books;
     people = People;
     logs   = Logs;
     Book   = targetBook;
     GetNames();
 }
        public BookBuilder(BookBLLCollection Books, PersonBLLCollection People, string ISBN)
        {
            books  = Books;
            people = People;
            iSBN   = ISBN;

            Book = new BookBLL()
            {
                ISBN = iSBN
            };
        }
        /// <summary>
        /// Searches the book collection for a book with an ISBN that matches the entered string.
        /// </summary>
        public void ISBNSearch()
        {
            FoundBooks = new List <BookBLL>();

            BookBLL book = (from b in books
                            where b.ISBN == QueryTerms
                            select b).FirstOrDefault();

            if (book != null)
            {
                FoundBooks.Add(book);
            }
        }
Пример #5
0
        /// <summary>
        /// When given a specific book will return how many copies have not been checked out yet.
        /// </summary>
        /// <param name="book"></param>
        /// <returns></returns>
        public int AvailableCopies(BookBLL book)
        {
            int availableCopies = book.NumberOfCopies;

            foreach (CheckOutLogBLL l in logs)
            {
                if (l.BookID == book.BookID)
                {
                    availableCopies--;
                }
            }
            return(availableCopies);
        }
        /// <summary>
        /// Takes each book and creates a list of strings from the fields to be searched for.
        /// </summary>
        /// <param name="b"></param>
        /// <returns></returns>
        List <string> ConcatenateBookFields(BookBLL b)
        {
            List <string> concatenatedFields = new List <string>();

            concatenatedFields.Add(b.Title);

            if (b.Subject != null)
            {
                concatenatedFields.Add(b.Subject);
            }

            PersonBLL author = (from a in people
                                where a.ID == b.AuthorID
                                select a).FirstOrDefault();

            concatenatedFields.Add(author.FirstName);
            concatenatedFields.Add(author.LastName);

            return(concatenatedFields);
        }
        /// <summary>
        /// Returns a list of formatted string to display cardholder information and checked out books.
        /// </summary>
        /// <returns></returns>
        public List <string> GetCardholderInformation()
        {
            List <CardholderBLL> cardholders = new List <CardholderBLL>();
            List <string>        stringArray = new List <string>();

            foreach (PersonBLL p in people)
            {
                if (p is CardholderBLL c)
                {
                    string output = c.ToString();
                    //get checkoutlogs that match the cardholder
                    List <CheckOutLogBLL> cardholdersLogs = logs.GetCheckOutLogBLLs(c.ID);
                    if (cardholdersLogs.Count > 0)
                    {
                        output += " Checked Out: ";
                        List <BookBLL> borrowedBooks = new List <BookBLL>();
                        foreach (CheckOutLogBLL l in cardholdersLogs)
                        {
                            BookBLL book = (from b in books
                                            where b.BookID == l.BookID
                                            select b).FirstOrDefault();
                            borrowedBooks.Add(book);
                            foreach (BookBLL b in borrowedBooks)
                            {
                                output += b.ToString() + $", Date Checked: {l.CheckOutDate}";
                                if (l.IsOverDue())
                                {
                                    output += " OVERDUE";
                                }
                            }
                        }
                    }
                    stringArray.Add(output);
                }
            }
            return(stringArray);
        }
 public BookUpdater(BookBLLCollection Books, PersonBLLCollection People, CheckOutLogBLLCollection Logs, BookBLL targetBook, bool remove) : this(Books, People, Logs, targetBook)
 {
     RemoveCopies = remove;
 }