private bool RequestBooksReadingRoom(string[] wishlist) { if (library != null) { //Print(String.Format("{1} requested {0} books to read in reading room;", wishlist.Count(), Name)); Card = library.GiveBooksForReadingRoom(this, wishlist); if (Card != null) { if (Card.Count == wishlist.Length) { PrintToLog(String.Format("Our reader had requested a few books:{0}and library has allowed him to read them.", ConvertArrayToString(wishlist))); } else { PrintToLog(String.Format("Alas, our reader had requested a few books:{0}but he was given only those:{1}", ConvertArrayToString(wishlist), ConvertArrayToString <Book>(Card.ToArray()))); } return(true); } else { //Print(String.Format("Library can't allow to requested books.", Name)); PrintToLog(String.Format("Library can't allow to read requested books.", Name)); return(false); } } else { return(false); } }
public ReadingRoomCard GiveBooksForReadingRoom(Reader reader, String[] wishList) { lock (threadlock) { if (booksForReadingRoom.Count > 0) { Book temp; List <Book> books = new List <Book>(); for (int i = 0; i < wishList.Count(); ++i) { temp = booksForReadingRoom.Find(delegate(Book b) { return(b.Title.Equals(wishList[i])); }); if (temp != null) { books.Add(temp); output.deleteBookForReadingRoom(temp); booksForReadingRoom.Remove(temp); } } if (books.Count > 0)//костыль { ReadingRoomCard card = new ReadingRoomCard(reader, books); //readersInReadingRoom.Add(card); reader.Card = card; output.addToReadingRoom(reader); return(card); } else { return(null); } } else { return(null); } } }