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 ReturnBook(TakenBookRegister takenBooks, ReaderRegister readers, string isbn, out bool lateReturn) { lateReturn = false; TakenBook book = takenBooks.Get(isbn); if (DateTime.Now > book.ReturnDate) { lateReturn = true; } readers.MinusBookCount(book.Reader); takenBooks.Remove(book); }
public void Remove(TakenBook book) { allBooks.Remove(book); }
public void Add(TakenBook book) { this.allBooks.Add(book); }