private async Task <JsonResult> NotifyClientsAndGenerateVoteResultAsync(long commentId, int currentUserAccountId)
        {
            CommentAggregate commentAggregate = await _commentRepository.GetAggregateAsync(commentId, currentUserAccountId);

            await _notificationService.ClearCommentVoteNotificationsAsync(commentId, commentAggregate.CreatedByAccountId, currentUserAccountId);

            if (commentAggregate.CurrentUserVote != 0)
            {
                var notificationChange = new NotificationChange {
                    CreatedByAccountId     = currentUserAccountId,
                    CreatedOn              = _systemClock.UtcNow,
                    NotificationActionType = commentAggregate.CurrentUserVote > 0 ? NotificationActionType.Upvoted : NotificationActionType.Downvoted
                };
                await _notificationService.NotifyCommentOwnerAsync(commentId, notificationChange);
            }

            _notificationService.UpdateClientsAfterVote(commentAggregate);

            var model = new CommentVoteViewModel {
                CommentId       = commentId,
                VoteScore       = commentAggregate.VoteScore,
                CurrentUserVote = commentAggregate.CurrentUserVote
            };

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
 public void UpdateClientsAfterVote(CommentAggregate commentAggregate)
 {
     throw new System.NotImplementedException();
 }
Exemple #3
0
 public void BroadcastCountdownUpdate(CommentAggregate commentAggregate) => Hub.Clients.All.broadcastCommentUpdate(commentAggregate);
Exemple #4
0
 public static CommentViewModel ToCommentViewModel(this CommentAggregate commentAggregate)
 {
     return(Mapper.Map <CommentAggregate, CommentViewModel>(commentAggregate));
 }
Exemple #5
0
 public void UpdateClientsAfterVote(CommentAggregate commentAggregate) => _notificationHub.BroadcastCountdownUpdate(commentAggregate);