public static Dictionary <int, Book> ReturnBook(Dictionary <int, Book> bookList) { Console.WriteLine("How would you like to search for a book to return? (title or author)"); string userInput = Validator.DetermineTitleOrAuthor(); if (userInput == "title") { Console.Write("Enter title of the book: "); userInput = Console.ReadLine(); bool validTitle; if (validTitle = Validator.BookTitleValidator(bookList, userInput)) { int bookKey = BookApp.FindBookByTitle(bookList, userInput); bookList = BookApp.ReturnBook(bookList, bookKey); } } else if (userInput == "author") { Console.Write("Enter author name: "); userInput = Console.ReadLine(); bool validAuthor; if (validAuthor = Validator.BookAuthorValidator(bookList, userInput)) { int bookKey = BookApp.FindBookByAuthor(bookList, userInput); bookList = BookApp.ReturnBook(bookList, bookKey); } } else { Console.WriteLine("Sorry, not valid"); } return(bookList); }
public static Dictionary <int, Book> ActionFromList(Dictionary <int, Book> bookList) { Console.Write("\nWould you like to select a book? (y/n) "); if (Validator.YesNoAnswer()) { bool validNumber = false; int bookNum = 0; while (validNumber == false) { Console.Write($"Please select a book 1 through {bookList.Count}: "); bool realNumber = int.TryParse(Console.ReadLine(), out bookNum); if (realNumber == true && bookNum > 0 && bookNum <= bookList.Count) { validNumber = true; } } if (bookList[bookNum].Status == true) { Console.Write("Would you like to check that book out? (y/n) "); if (Validator.YesNoAnswer()) { bookList = BookApp.CheckOutBook(bookList, bookNum); } } else if (bookList[bookNum].Status == false) { Console.Write("Would you like to return that book? (y/n) "); if (Validator.YesNoAnswer()) { bookList = BookApp.ReturnBook(bookList, bookNum); } } } return(bookList); }