public void AddBook(Book Book, int Copies) { if (BookCollection.ContainsKey(Book)) { Console.WriteLine($"Book {Book} is allready in the collection of {Name}."); return; } BookCollection.Add(Book, new BookStock(Copies)); }
public bool SearchBook(Book aBook, out int availableCopies) { if (BookCollection.ContainsKey(aBook)) { availableCopies = BookCollection[aBook].AvailableBooks; return(true); } availableCopies = 0; return(false); }
public string Rent(Book aBook, Person aPerson) { if (BookCollection.ContainsKey(aBook)) { if (isMember(aPerson)) { if (BookCollection[aBook].AvailableBooks > 0) { Rentals.Add(new Rental(aBook, aPerson)); BookCollection[aBook].AvailableBooks--; return($"Here is your book. Please remember to bring it back in 10 days!"); } return($"Sorry we have not any copies available."); } return($"Sorry, {aPerson} is not a member of our library."); } return($"{aBook} is not in our collection."); }
public string Return(Book aBook, Person aPerson) { if (BookCollection.ContainsKey(aBook)) { if (isMember(aPerson)) { foreach (Rental rental in Rentals) { if (rental.Renter.Equals(aPerson) && rental.RentedBook.Equals(aBook) && !rental.isCompleted) { rental.ReturnBook(); BookCollection[aBook].AvailableBooks++; return($"Thank you for returning the book!"); } } return($"Sorry, according to our records you have not rented this book."); } return($"Sorry, {aPerson} is not a member of our library."); } return($"{aBook} is not in our collection."); }