Пример #1
0
        public async Task <ViewReplyDto> AddReply(string userId, int commentId, ReplyDto replyDto)
        {
            var comment = await GetComment(commentId);

            var reply = new Reply
            {
                Content   = replyDto.Content,
                CommentId = commentId,
                UserId    = userId
            };

            await Do(async() => await _context.Replies.AddAsync(reply));

            reply.User = await _userService.GetUserById(userId);

            if (userId != comment.UserId)
            {
                await _notificationService.NotifyReply(reply.User, comment, reply.Id);
            }

            var dto = ViewReplyDto.Create(reply);

            _topicsHub.SendReply(comment.TopicId, dto);

            return(dto);
        }
Пример #2
0
 public static async void SendReply(this IHubContext <TopicsHub> hub, int topicId, ViewReplyDto reply)
 {
     await hub.Clients.Group(topicId.ToString()).SendAsync("ReceiveReply", reply);
 }