static void GiveOut(int bookIndex, string clientName, Entities.Catalogue library) { if (bookIndex > library.catalogue.Count || bookIndex < 0) { throw new ArgumentOutOfRangeException("\n\nI can't give out the book. bookIndex is out of range of catalogue."); } Entities.Book book = library.catalogue[bookIndex]; if (book.Available == false) { throw new Exceptions.UnAvailableBookException("\n\nI can't give out the book. This book is given out!!!"); } Entities.LibraryCard card = library.clientCards.Find(item => item.Reader.Name == clientName); if (card == null) { throw new Exceptions.InexistentClientException("\n\nI can't give out the book. There is no such Client! "); } else { book.Available = false; card.clientBookList.Add(book, DateTime.Today); } }
static void GetBack(int bookIndex, string clientName, Entities.Catalogue library) { if (bookIndex > library.catalogue.Count || bookIndex < 0) { throw new ArgumentOutOfRangeException("\n\nI can't take the book. bookIndex is out of range of catalogue."); } Entities.Book book = library.catalogue[bookIndex]; if (book.Available == true) { throw new Exceptions.UnAvailableBookException("\n\nI can't take the book. This book is available already!!!"); } Entities.LibraryCard card = library.clientCards.Find(item => item.Reader.Name == clientName); if (card == null) { throw new Exceptions.InexistentClientException("\n\nI can't take the book. There is no such Client! "); } else { book.Available = true; Boolean rezult = card.clientBookList.Remove(book); if (rezult == false) { throw new Exceptions.NoCardRecordException("\n\nI can't take the book. Client did not take the book!!!"); } } }