public void AddBook(Book book)
 {
     if (book.Available)
     {
         AvailableBooks.Add(book);
     }
     else
     {
         CheckedOutBooks.Add(book);
     }
 }
예제 #2
0
        // RETURN BOOK
        public void ReturnBook(string selection)
        {
            Book selectedBook = ValidateBook(CheckedOut, selection);

            if (selectedBook == null)
            {
                Console.WriteLine(" Invalid Selection");
                return;
            }
            else
            {
                selectedBook.Available = true;
                AvailableBooks.Add(selectedBook);
                CheckedOut.Remove(selectedBook);
                Console.Clear();
                Console.WriteLine(" Book Returned!");
            }
        }
예제 #3
0
        public void ReturnBook(string input)
        {
            Book selectedBook = ValidateBook(input, CheckedOutBooks);

            if (selectedBook == null)
            {
                Console.Clear();
                System.Console.WriteLine("Invalid Selection... Press enter to continue");
                Console.ReadLine();
                return;
            }
            //set available to false, add book to checked out and remove from available array
            selectedBook.Available = true;
            AvailableBooks.Add(selectedBook);
            CheckedOutBooks.Remove(selectedBook);
            Console.Clear();
            System.Console.WriteLine($"Thanks for returning {selectedBook.Title}!");
        }
예제 #4
0
        public void ReturnBook(string selection)
        {
            Book selectedBook = ValidateBook(selection, CheckedOut);

            if (selectedBook == null || selectedBook.Available == true)
            {
                Console.Clear();
                System.Console.WriteLine(@"Invalid Selection");
                return;
            }
            else
            {
                selectedBook.Available = true;
                AvailableBooks.Add(selectedBook);
                CheckedOut.Remove(selectedBook);
                System.Console.WriteLine("Congrats my Dude, Book is back");
            }
        }
예제 #5
0
        public void ReturnBook(string selection)
        {
            //checkout book
            Book selectedBook = ValidateUserSelection(selection, CheckedOut);

            if (selectedBook == null)
            {
                System.Console.WriteLine(@"Invalid Selection, please make a valid selection: 1
                ");
                return;
            }

            selectedBook.Available = true;
            AvailableBooks.Add(selectedBook);
            CheckedOut.Remove(selectedBook);
            Console.Clear();
            System.Console.WriteLine("Successfully Returned Book!");
        }
        public void ReturnBook()
        {
            System.Console.WriteLine("Enter the number of the book you'd like to return.");
            ViewBooks(CheckedOutBooks);
            Book bookToReturn = ValidateUserInput(CheckedOutBooks);

            // null check to prevent breaking errors
            if (bookToReturn == null)
            {
                return;
            }
            // if found a book to return then:
            // 1. reassign the available property to true
            // 2. remove the book from the checkoutbooks list
            // 3. add the book to the availablebooks list
            bookToReturn.Available = true;
            CheckedOutBooks.Remove(bookToReturn);
            AvailableBooks.Add(bookToReturn);
            System.Console.WriteLine("Thanks for returning {0}!", bookToReturn.Title);
        }
예제 #7
0
        public bool AddNewBook(Book book, double price, int quantity = 1)
        {
            var validationService = _dependencyService.Get <IValidationService>();

            if (validationService.isValidBook(book) &&
                validationService.IsValidPrice(price) &&
                validationService.IsValidQuantity(quantity))
            {
                var searchedIndex = AvailableBooks.FindIndex(item => item.Book.ISBN == book.ISBN);
                if (searchedIndex == -1)
                {
                    AvailableBooks.Add(new BookProductInfo {
                        Book = book, BorrowPrice = price, Quantity = quantity
                    });

                    return(true);
                }
            }

            return(false);
        }
예제 #8
0
 public void AddBook(Book book)
 {
     AvailableBooks.Add(book);
 }
예제 #9
0
 internal void addBook(Book book)
 {
     AvailableBooks.Add(book);
 }