public bool LendBook(Account user, Book book) { var bookItem = new BookItem(); char bookLetter = book.Title.ToUpper()[0]; foreach (var rack in this.Racks) { if (rack.Letters.Contains(bookLetter)) { bookItem = rack.BookItems.Find(bI => bI.Book == book); if (bookItem == null) { return(false); } var bookLending = new BookLending { BookItem = bookItem, User = user, Date = DateTime.Now }; this.System.BookLendings.Add(bookLending); rack.BookItems.Remove(bookItem); break; } } return(true); }
public void AddBook(Book book) { char bookLetter = book.Title.ToUpper()[0]; foreach (var rack in this.Racks) { if (rack.Letters.Contains(bookLetter)) { var bookItem = new BookItem(); // pravin si kopie na knigata koqto se dobavq bookItem.Book = book; bookItem.Rack = rack; rack.BookItems.Add(bookItem); // tuk sudurjame fizicheskite kopiq na edna kniga break; } } if (this.Books.Add(book)) { this.Catalog.AddBook(book); } }
public void ReserveBook(Account user, Book book) { var bookItem = new BookItem(); char bookLetter = book.Title.ToUpper()[0]; foreach (var rack in this.Racks) { if (rack.Letters.Contains(bookLetter)) { bookItem = rack.BookItems.Find(bR => bR.Book == book); var bookReserv = new BookReservation { BookItem = bookItem, User = user, Date = DateTime.Now }; this.System.BookReservations.Add(bookReserv); break; } } }