private void button3_Click(object sender, EventArgs e) // search by author { listBox1.Items.Clear(); List <Book> ToPrint = LibraryApp.LookByAuthor(ref BookList, textBox2.Text); if (ToPrint.Count == 0) { MessageBox.Show("No books matched that search!"); } else { PrintTitles(ToPrint); } }
//public static Book ConfirmReturn(List<Book> CheckedOut, int BookIndex) //{ // while (true) // { // if (BookIndex > 0 && BookIndex <= CheckedOut.Count) // return CheckedOut[BookIndex]; // else // { // Console.WriteLine("I didn't understand. Try again!"); // int.TryParse(Console.ReadLine(), out BookIndex); // } // } //} public static void Search(ref List <Book> BookList) { Console.WriteLine("Do you want to search by Title or Author? (t/a)"); string TorA = Console.ReadLine().ToLower(); if (Regex.IsMatch(TorA, "^(t|title)$")) { Console.WriteLine("Please enter a title..."); string Input = Console.ReadLine(); Menu.PrintTitles(LibraryApp.LookByTitleKeyword(ref BookList, Input)); } if (Regex.IsMatch(TorA, "^(a|author)$")) { Console.WriteLine("Please enter an author..."); string Input = Console.ReadLine(); Menu.PrintTitles(LibraryApp.LookByAuthor(ref BookList, Input)); } }