public void AddWord(string inputWord, string userIp) { if (!_wordRepository.GetWordsDictionary().Contains(inputWord)) { _wordRepository.AddWord(inputWord); _userManagingService.GiveUserAdditionalSearch(userIp); } }
public IActionResult Add(WordModel model) { if (!ModelState.IsValid) { return(View(model)); } repo.AddWord(model); return(RedirectToAction("Index")); }
public bool HasWordBeenAdded(string input) { var words = new Words() { Word = input }; _wordRepository.AddWord(words); return(true); }
public async Task <IHttpActionResult> AddEnglishWord(EnglishWord word) { var resultData = await _englishWordRepository.AddWord(word); if (resultData == false) { return(InternalServerError()); } else { return(Ok()); } }
public static void Seed(IWordRepository repo) { repo.ClearWords(); //repo.AddWord("about"); //repo.AddWord("their"); //repo.AddWord("would"); repo.AddWord("dictionary"); //repo.AddWord("campaign"); //repo.AddWord("candidate"); //repo.AddWord("challenge"); //repo.AddWord("economy"); //repo.AddWord("education"); //repo.AddWord("government"); //repo.AddWord("information"); //repo.AddWord("leader"); //repo.AddWord("magazine"); //repo.AddWord("opportunity"); //repo.AddWord("professional"); //repo.AddWord("situation"); //repo.AddWord("understand"); }
protected ImportWordResult UploadWords(ImportWordResult importedResult, long userId) { var badWords = new List <string>(); var goodWords = new List <Word>(); foreach (var word in importedResult.SuccessfulWords) { try { UploadFiles(word); _repository.AddWord(word, userId); goodWords.Add(word); } catch (Exception ex) { Trace.WriteLine(ex); badWords.Add(ex.Message); } } badWords.AddRange(importedResult.FailedWords); return(new ImportWordResult(goodWords.ToArray(), badWords.ToArray())); }
public async Task <UserWord> AddWord(Word word, string userId) { if (string.IsNullOrEmpty(userId)) { throw new EmptyUserIdException(); } if (string.IsNullOrEmpty(word.Spelling)) { throw new EmptySpellingException(); } Word currentWord = await _wordRepository.GetWord(word.Id) ?? (await _wordRepository.GetWord(word.Spelling) ?? await _wordRepository.AddWord(word)); UserWord userWord = await _learningRepository.GetUserWord(currentWord.Id, userId) ?? await _learningRepository.AddUserWord(new UserWord { WordId = currentWord.Id, UserId = userId }); return(userWord); }
public ViewResult AddWord(Word word) { repository.AddWord(word); return(View()); }
public void RunGame() { while (true) { Console.WriteLine("Choose an option:"); Console.WriteLine("P: Play game"); Console.WriteLine("S: Seed words. This will override all previously added words"); Console.WriteLine("A: Append word"); Console.WriteLine("H: High scores"); Console.WriteLine("Esc: Quit game"); var c = Console.ReadKey(true); switch (c.Key) { case ConsoleKey.P: Console.Clear(); StartGame(); break; case ConsoleKey.S: Console.Clear(); GameInitializer.Seed(repo); Console.WriteLine("Seeding Done"); break; case ConsoleKey.A: Console.Clear(); Console.WriteLine("Input the word followed by enter:"); repo.AddWord(Console.ReadLine().ToLower()); break; case ConsoleKey.H: Console.Clear(); repo.GetHighscores(5); break; case ConsoleKey.Escape: return; default: break; } } }