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(); } })); }
public ActionResult AddInterpretation(string wordId, WordInterpretationDto interpretationDto) { var result = _maintainService.AddWordInterpretation(wordId, interpretationDto); return(OperationJsonResult(result)); }