コード例 #1
0
        public void AddWord(int wordId, int vocabularyId)
        {
            var word       = _unitOfWork.WordRepository.Get(wordId);
            var vocabulary = _unitOfWork.VocabularyRepository.Get(vocabularyId);

            if (word == null || vocabulary == null)
            {
                return;
            }

            var old = _unitOfWork.WordVocabularyRepository.Get(
                x => x.WordId == wordId && x.VocabularyId == vocabularyId);

            if (old != null)
            {
                return;
            }

            var model = new WordVocabulary
            {
                WordId       = wordId,
                VocabularyId = vocabularyId
            };

            _unitOfWork.WordVocabularyRepository.Create(model);
            _unitOfWork.Commit();
        }
コード例 #2
0
        public void DeleteCustomWord(int userid, int wordId)
        {
            Word       word          = _wordService.Get(wordId);
            Vocabulary ownVocabulary = GetByUser(userid).First(v => v.IsPrivate);
            var        model         = new WordVocabulary
            {
                VocabularyId = ownVocabulary.Id,
                WordId       = word.Id
            };

            _unitOfWork.WordVocabularyRepository.Delete(model);
            _unitOfWork.Commit();
        }