public async Task <bool> Handle(RegisterAnswerCommentCommand request, CancellationToken cancellationToken) { var question = await _questionRepository.GetByIdAsync(request.QuestionId); if (question == null) { return(false); } var answer = question.Answers.ToList().FirstOrDefault(answer => answer.Id == request.AnswerId); if (answer == null) { return(false); } var comment = new CommentEntity( request.UserId, request.Body ); comment.DefineId(request.Id); comment.SetParent(answer); await _repository.RegisterCommentAsync(comment); return(true); }
public CommentEntity Execute(AnswerModel from) { var entity = new CommentEntity( from.UserId, from.Body ); entity.DefineId(from.Id); return(entity); }
public async Task <bool> Handle(RegisterQuestionCommentCommand request, CancellationToken cancellationToken) { var question = await _questionRepository.GetByIdAsync(request.QuestionId); if (question == null) { return(false); } var comment = new CommentEntity( request.UserId, request.Body ); comment.DefineId(request.Id); comment.SetParent(question); await _questionRepository.RegisterCommentAsync(comment); return(true); }