/// <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);
        }
 /// <summary>
 /// Finishes the cardholderBLL creation.
 /// </summary>
 public void CreateCardholder()
 {
     Cardholder = new CardholderBLL()
     {
         FirstName     = firstName,
         LastName      = lastName,
         Phone         = phone,
         LibraryCardID = libraryCardID,
         ID            = iD
     };
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a list of business logic layer objects from the database tables
 /// </summary>
 public void PopulatePeople()
 {
     using (LibraryDBEntities context = new LibraryDBEntities())
     {
         List <PersonBLL> newPeople = new List <PersonBLL>();
         //Add the librarians
         LibrarianBLL librarian = null;
         foreach (Librarian l in context.Librarians)
         {
             librarian = new LibrarianBLL()
             {
                 ID        = l.Person.PersonID,
                 FirstName = l.Person.FirstName,
                 LastName  = l.Person.LastName,
                 Phone     = l.Phone,
                 UserID    = l.UserID,
                 Password  = l.Password
             };
             newPeople.Add(librarian);
         }
         //Add the authors
         AuthorBLL author = null;
         foreach (Author a in context.Authors)
         {
             author = new AuthorBLL()
             {
                 ID        = a.Person.PersonID,
                 FirstName = a.Person.FirstName,
                 LastName  = a.Person.LastName,
                 Bio       = a.Bio
             };
             newPeople.Add(author);
         }
         //Add cardholders
         CardholderBLL cardholder = null;
         foreach (Cardholder c in context.Cardholders)
         {
             cardholder = new CardholderBLL()
             {
                 ID            = c.Person.PersonID,
                 FirstName     = c.Person.FirstName,
                 LastName      = c.Person.LastName,
                 Phone         = c.Phone,
                 LibraryCardID = c.LibraryCardID
             };
             newPeople.Add(cardholder);
         }
         people = newPeople;
     }
     Sort();
 }