public UserPromptService(IConsolePrinterService consolePrinterService, IConsoleKeyMapperService consoleKeyMapperService, IJokesJsonFeedService jsonFeedService, IPersonService personService, IMemoryCache cache ) { printer = consolePrinterService; keyMapper = consoleKeyMapperService; jsonFeed = jsonFeedService; personFeed = personService; _cache = cache; }
private async Task GetRandomJokesByCount(IConsolePrinterService printer, bool randomPerson, string category) { printer.PrintMessage(Constants.JokesCountPrompt); char key = keyMapper.GetEnteredKey(Console.ReadKey()); // check if the joke count is a valid integer if (Int32.TryParse(key.ToString(), out int n)) { printer.PrintNewline(); string[] results = await GetRandomJokesAsync(randomPerson?await GetRandomPersonAsync() : null, category, n); PrintResults(printer, results); } else { printer.PrintNewline(); printer.PrintErrorMessage(Constants.ErrorInvalidJokeCount); } }
public void PrintCategoryResults(IConsolePrinterService printer, string[] results) { // display categories printer.PrettyPrintCategories(results); }
public void PrintResults(IConsolePrinterService printer, string[] results) { // display jokes printer.PrettyPrintResults(results); }