Ejemplo n.º 1
0
 public void AddWord(string inputWord, string userIp)
 {
     if (!_wordRepository.GetWordsDictionary().Contains(inputWord))
     {
         _wordRepository.AddWord(inputWord);
         _userManagingService.GiveUserAdditionalSearch(userIp);
     }
 }
Ejemplo n.º 2
0
 public IActionResult Add(WordModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     repo.AddWord(model);
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 3
0
        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());
            }
        }
Ejemplo n.º 5
0
 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");
 }
Ejemplo n.º 6
0
        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()));
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
 public ViewResult AddWord(Word word)
 {
     repository.AddWord(word);
     return(View());
 }
Ejemplo n.º 9
0
        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;
                }
            }
        }