public UnifyResponseDto Post([FromBody] CreateUpdatePoemDto createPoem)
        {
            LinPoem poem = _mapper.Map <LinPoem>(createPoem);

            _poemRepository.Insert(poem);
            return(UnifyResponseDto.Success("新建诗词成功"));
        }
        public UnifyResponseDto Put(long id, [FromBody] CreateUpdatePoemDto updatePoem)
        {
            LinPoem poem = _poemRepository.Select.Where(r => r.Id == id).ToOne();

            if (poem == null)
            {
                throw new LinCmsException("没有找到诗词");
            }

            _mapper.Map(updatePoem, poem);
            _poemRepository.Update(poem);
            return(UnifyResponseDto.Success("更新诗词成功"));
        }
예제 #3
0
        public ResultDto Put(long id, [FromBody] CreateUpdatePoemDto updatePoem)
        {
            LinPoem poem = _poemRepository.Select.Where(r => r.Id == id).ToOne();

            if (poem == null)
            {
                throw new LinCmsException("没有找到诗词");
            }

            //使用AutoMapper方法简化类与类之间的转换过程
            _mapper.Map(updatePoem, poem);

            _poemRepository.Update(poem);

            return(ResultDto.Success("更新诗词成功"));
        }