public IActionResult CreateComment([FromBody] CommentCardDto commentDto) { var userId = User.GetUserId(); var addedComment = _cardService.AddCommentToCard(commentDto, userId); if (addedComment == null) { return(BadRequest()); } _cardDetailsHub.Clients.Group(commentDto.CardId.ToString()).AddComment(addedComment); return(Ok(addedComment)); }
public CommentDto AddCommentToCard(CommentCardDto commentDto, string userId) { if (!_cardRepository.IsMember(commentDto.CardId, userId)) { return(null); } var comment = _mapper.Map <Comment>(commentDto); comment.UserId = userId; var addedComment = _commentRepository.CreateComment(comment); var result = _mapper.Map <CommentDto>(addedComment); result.IsOwner = true; return(result); }