private AnswerContent convertToAnswerContent(AnswerForm form, User user) { AnswerContent answerContent = new AnswerContent(); answerContent.setBody(form.getBody()); answerContent.setDate(new Date()); answerContent.setChangeLog(form.getChangeLog()); answerContent.setUser(user); return answerContent; }
@Override public Answer edit(AnswerForm answerForm, User user) { AnswerContent content = convertToAnswerContent(answerForm, user); answerContentRepository.save(content); Answer answer = answerRepository.findOne(answerForm.getId()); answer.setContent(content); answer.getContentHistory().add(content); answerRepository.save(answer); return answer; }