public ActionResult GetBannedWords() { try { var response = _badWordRepository.GetBannedWords(); return(Ok(response)); } catch (Exception e) { return(StatusCode((int)HttpStatusCode.BadRequest, e.Message)); } }
private ProfanityFileResponse ScanFile(IFormFile file) { var fileText = File.ReadAllText(Path.Combine(basePath, file.FileName)); var badWords = _badWordRepository.GetBannedWords(); int badWordCount = 0; foreach (var word in fileText.Split(' ')) { if (badWords.Any(x => x.Equals(word, StringComparison.InvariantCultureIgnoreCase))) { badWordCount++; } } return(new ProfanityFileResponse { IsAppropriate = badWordCount == 0, BadWordCount = badWordCount }); }