Esempio n. 1
0
        public async Task <Guid> RegisterQuestionComment(QuestionCommentRequest request)
        {
            var commentId = Guid.NewGuid();
            var command   = new RegisterQuestionCommentCommand
            {
                Id         = commentId,
                Body       = request.Body,
                UserId     = request.UserId,
                QuestionId = request.QuestionId,
            };

            await _mediator.Send(command);

            return(commentId);
        }
Esempio n. 2
0
        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);
        }