예제 #1
0
        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);
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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;
                }
            }
        }