public static void TakeBook(BookRegister allBooks, TakenBookRegister takenBooks, ReaderRegister readers, string isbn, string readerName, DateTime returnDate, out bool successful, int maxBookCount) { successful = false; if (!takenBooks.Contains(isbn) && allBooks.Contains(isbn)) { Book book = allBooks.Get(isbn); if (readers.Contains(readerName)) { Reader reader = readers.Get(readerName); if (reader.BookCount < maxBookCount) { readers.AddBookCount(reader); TakenBook takenBook = new TakenBook(book, returnDate, reader); takenBooks.Add(takenBook); successful = true; } } else { Reader reader = new Reader(readerName); readers.Add(reader); TakenBook takenBook = new TakenBook(book, returnDate, reader); takenBooks.Add(takenBook); successful = true; } } }
public static void DeleteBook(TakenBookRegister takenBooks, BookRegister allBooks, ReaderRegister readers, string isbn) { Book bookToDelete = allBooks.Get(isbn); allBooks.Remove(bookToDelete); if (takenBooks.Contains(isbn)) { bool lateReturnal; ReturnBook(takenBooks, readers, isbn, out lateReturnal); } }
public static void PrintBooks(BookRegister books) { string horizontalGridLine = new string('-', 125); Console.WriteLine(horizontalGridLine); Console.WriteLine(String.Format("| {0,-20} | {1,-20} | {2,-20} | {3,-10} | {4,-16} | {5,-20} |", "Name", "Author", "Category", "Language", "Publication Date", "ISBN")); Console.WriteLine(horizontalGridLine); for (int i = 0; i < books.Count(); i++) { Console.WriteLine(books.Get(i)); } Console.WriteLine(horizontalGridLine); }