public static bool ProceedToFindRent(Reader user) { Book res = null; Console.Clear(); Console.BackgroundColor = menuBackColor; Console.ForegroundColor = menuFontColor; Console.WriteLine("| Esc - exit | Enter - choose| Up, Down arrows - navigate |"); Console.BackgroundColor = titleBackColor; Console.ForegroundColor = titleFontColor; Console.WriteLine("| FIND BOOK |"); Console.BackgroundColor = noticeBackColor; Console.ForegroundColor = noticeFontColor; Console.WriteLine("Input word to search for: "); Console.ResetColor(); string input = string.Empty; int index = 0; int selectedIndex = 0; List <Book> foundBooks = new List <Book>(); while (true) { foundBooks = rental.FindBooks(input).GroupBy(book => book.Name).Select(g => g.First()).ToList(); index = 0; Console.Clear(); Console.BackgroundColor = menuBackColor; Console.ForegroundColor = menuFontColor; Console.WriteLine("| Esc - exit | Enter - choose| Up, Down arrows - navigate |"); Console.BackgroundColor = titleBackColor; Console.ForegroundColor = titleFontColor; Console.WriteLine("| FIND BOOK |"); Console.BackgroundColor = noticeBackColor; Console.ForegroundColor = noticeFontColor; Console.WriteLine(">Input word to search for: "); Console.ResetColor(); Console.BackgroundColor = choiceBackColor; Console.ForegroundColor = choiceFontColor; Console.WriteLine(">" + input); Console.ResetColor(); Console.BackgroundColor = noticeBackColor; Console.ForegroundColor = noticeFontColor; Console.WriteLine(">Select book using arrows"); Console.ResetColor(); Console.WriteLine(foundBooks.Count != 0 ? ">Available books: " : "No books available"); if (foundBooks.Count > 0) { OptimisedListRender(selectedIndex, foundBooks); } ConsoleKeyInfo keyInfo = Console.ReadKey(intercept: true); ConsoleKey key = keyInfo.Key; if (key == ConsoleKey.UpArrow) { if (selectedIndex > 0) { selectedIndex--; } } else if (key == ConsoleKey.DownArrow) { if (selectedIndex < foundBooks.Count - 1) { selectedIndex++; } } else if (key == ConsoleKey.Enter) { break; } else if (key == ConsoleKey.Escape) { return(false); } else if (key == ConsoleKey.Backspace) { selectedIndex = 0; if (!string.IsNullOrEmpty(input)) { input = input.Substring(0, input.Length - 1); } } else { if ((keyInfo.Modifiers & ConsoleModifiers.Shift) != 0) { input += key.ToString(); } else { input += key.ToString().ToLower(); } } } if (foundBooks.Count <= 0) { Console.WriteLine(); Console.WriteLine("Noting found, press any key to return..."); while (true) { if (Console.ReadKey() != null) { break; } } return(false); } res = foundBooks[selectedIndex]; if (res != null) { Console.Clear(); Console.Clear(); Console.BackgroundColor = titleBackColor; Console.ForegroundColor = titleFontColor; Console.Clear(); Console.BackgroundColor = menuBackColor; Console.ForegroundColor = menuFontColor; Console.WriteLine("| Esc - exit | Enter - choose| Up, Down arrows - navigate |"); Console.BackgroundColor = titleBackColor; Console.ForegroundColor = titleFontColor; Console.WriteLine("| FIND BOOK |"); Console.BackgroundColor = infoBackColor; Console.ForegroundColor = infoFontColor; Console.WriteLine(">User: "******"\n" + ">Book: " + res.Name); Console.ResetColor(); Console.WriteLine(rental.TryRentBook(res, user) ? "Rented successfully" : "Error, coludn't rent"); Console.WriteLine("\n" + "Press any key to proceed..."); while (true) { if (Console.ReadKey() != null) { break; } } return(true); } else { Console.WriteLine("No such book available"); return(false); } }