public Content GetUserInput(string userInput) { var content = new Content(); List <string> bannedWords = _apiService.GetNegativeWordsAsync(); content.InputUnformatted = userInput; content.InputFormatted = Regex.Replace(userInput, @"[^\w\s]", ""); content.InputFiltered = FilterHelper.FilterOutString(userInput, "#", bannedWords); return(content); }
public static void RunAdminPath(INegativeWordsApiService apiService, IUserInputProcessor userInputProcessor) { Console.WriteLine($"Please select action - R - to read current negative word, A to add new negative words or D to remove existing negative word."); var action = Console.ReadLine(); switch (action.ToUpper()) { case "A": { Console.WriteLine($"Please type in new word."); var newWord = Console.ReadLine(); apiService.AddNegativeWords(newWord.ToLower()); Console.WriteLine($"Current words library: "); var words = apiService.GetNegativeWordsAsync(); words.ForEach(x => Console.WriteLine($"{x}")); break; } case "D": { var currentWords = apiService.GetNegativeWordsAsync(); Console.WriteLine($"You can remove words from below list of {currentWords.Count}: "); currentWords.ForEach(x => Console.WriteLine($"{x}")); Console.WriteLine($"Please type word to remove."); var word = Console.ReadLine(); apiService.RemoveNegativeWords(word.ToLower()); var words = apiService.GetNegativeWordsAsync(); Console.WriteLine($"Current words library cointains {words.Count} words: "); words.ForEach(x => Console.WriteLine($"{x}")); break; } case "R": { var words = apiService.GetNegativeWordsAsync(); words.ForEach(x => Console.WriteLine($"{x}")); break; } default: break; } GetUserInputWithoutFilter(userInputProcessor); }