Ejemplo n.º 1
0
        public ActionResult AddInterpretation(string wordId, WordInterpretationDto interpretationDto)
        {
            var result = _maintainService.AddWordInterpretation(wordId, interpretationDto);

            return OperationJsonResult(result);
        }
Ejemplo n.º 2
0
        public HangerdResult<bool> AddWordInterpretation(string wordId, WordInterpretationDto interpretationDto)
        {
            return TryOperate(() =>
            {
                using (var unitOfWork = DbContextFactory.CreateContext())
                {
                    var wordRepository = unitOfWork.GetRepository<IWordRepository>();
                    var word = wordRepository.Get(wordId, true, w => w.Interpretations);

                    Requires.NotNull(word, "单词信息不存在");

                    word.AddInterpretation((PartOfSpeech)interpretationDto.PartOfSpeech, interpretationDto.Interpretation);

                    wordRepository.Update(word);

                    unitOfWork.Commit();
                }
            });
        }