//Fills the CheckOutLogs table with data from local xml
        private void LoadCheckOutLogFromXML()
        {
            try
            {
                XDocument checkoutDocument = XDocument.Load("XML Files/CheckOutLog.xml");

                var checkOutLogs = (from col in checkoutDocument.Descendants("CheckOutLog")
                                    select col).ToList();

                foreach (var checkOutLog in checkOutLogs)
                {
                    int id; int.TryParse(checkOutLog.Element("CheckOutLogID").Value, out id);

                    string     cardholderID = checkOutLog.Element("CardholderID").Value;
                    Cardholder cardHolder   = (from ch in context.Cardholders
                                               where ch.PersonId.ToString() == cardholderID
                                               select ch).First();

                    string bookID = checkOutLog.Element("BookID").Value;
                    Book   book   = (from b in context.Books
                                     where b.BookId.ToString() == bookID
                                     select b).First();

                    DateTime checkOutDate; DateTime.TryParse(checkOutLog.Element("CheckOutDate").Value, out checkOutDate);
                    if (checkOutDate.CompareTo(DateTime.MinValue) == 0)
                    {
                        checkOutDate = SqlDateTime.MinValue.Value;
                    }

                    DateTime checkInDate; DateTime.TryParse(checkOutLog.Element("CheckInDate").Value, out checkInDate);
                    if (checkInDate.CompareTo(DateTime.MinValue) == 0)
                    {
                        checkInDate = SqlDateTime.MinValue.Value;
                    }

                    //Only create and add checkout log if the book is checked out.
                    if (checkInDate < checkOutDate)
                    {
                        CheckOutLog newCheckOutLog = new CheckOutLog
                        {
                            CheckOutLogId = id,
                            Cardholder    = cardHolder,
                            Book          = book,
                            CheckOutDate  = checkOutDate
                                            //CheckInDate = checkInDate
                        };

                        context.CheckOutLogs.Add(newCheckOutLog);
                    }
                }

                context.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Exception checkoutException = new Exception("CheckOut", ex);
                throw checkoutException;
            }
        }
        //Loads the CardHolders Table from local XML file
        private void LoadCardHoldersFromXML()
        {
            try
            {
                //XDocument peopleDocument = XDocument.Load("XML Files/People.xml");
                XDocument cardholdersDocument = XDocument.Load("XML Files/Cardholders.xml");

                // var people = (from p in peopleDocument.Descendants("Person")
                //               select p).ToList();

                var cardholders = (from ch in cardholdersDocument.Descendants("Cardholder")
                                   select ch).ToList();

                foreach (var cardholder in cardholders)
                {
                    //string firstName, lastName;
                    //LoadFirstLastNameFromXML(people, cardholder.Element("ID").Value, out firstName, out lastName);

                    int id; int.TryParse(cardholder.Element("ID").Value, out id);

                    Cardholder newCardHolder = new Cardholder
                    {
                        PersonId = id,
                        //FirstName = firstName,
                        //LastName = lastName,
                        Phone         = cardholder.Element("Phone").Value,
                        LibraryCardId = cardholder.Element("LibraryCardID").Value,
                        Person        = (from p in context.People
                                         where p.PersonId == id
                                         select p).First()
                    };

                    context.Cardholders.Add(newCardHolder);
                    //context.People.Add(newCardHolder);
                }

                context.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Exception chEx = new Exception("CardHolder", ex);
                throw chEx;
            }
        }