public void DeleteWord(int wordId)
        {
            Word wordToDelete = _dbContext.Words.SingleOrDefault(w => w.Id == wordId);

            _dbContext.Words.Remove(wordToDelete);
            _dbContext.SaveChanges();
        }
Exemplo n.º 2
0
        public void AddUserLog(UserSearchLogModel userLog, string wordSearched)
        {
            _dbContext.SearchLogs
            .Add(
                new SearchLog()
            {
                SearchDate   = userLog.SearchDate,
                UserIP       = userLog.UserIP,
                WordSearched = wordSearched
            });

            _dbContext.SaveChanges();
        }
        public void UpdateAnagramsCache(string word, List <WordModel> anagrams)
        {
            foreach (WordModel anagram in anagrams)
            {
                _dbContext.Add(new CachedWord()
                {
                    Word = word, AnagramWord = _dbContext.Words.SingleOrDefault(w => w.Id == anagram.Id)
                });
            }

            _dbContext.SaveChanges();
        }