Ejemplo n.º 1
0
        private async Task SendCommentLikedEventAsync(Guid likingUserId, Domain.AggregatesModel.CommentAggregate.Comment comment)
        {
            var post = await _postRepository.GetByIdAsync(comment.PostId);

            var @event = new CommentLikedEvent
            {
                LikingUserId  = likingUserId,
                PostUserId    = post.UserId,
                PostId        = comment.PostId,
                CommentUserId = comment.UserId,
                CommentId     = comment.Id,
                CommentText   = comment.Text
            };

            await SendEvent(@event);
        }
Ejemplo n.º 2
0
        private void Handle(CommentLikedEvent commentLikedEvent, string eventDataJson, EventModel @event, EventMetaData eventMetaData)
        {
            _logger.LogInformation($"Handling {nameof(CommentLikedEvent)} .... {Environment.NewLine} {eventDataJson}");

            _operation          = DatabaseOperation.Update;
            _currentValueRecord = GetRecord(commentLikedEvent.ParentId);

            ThrowIfRecordIsNull(commentLikedEvent, _currentValueRecord);

            // there must exist a comment record already before we can update it!
            var comment = _currentValueRecord.Comments.First(x => x.PublicId == commentLikedEvent.Id);

            comment.Likes += 1;

            UpdateCommonFields(@event, eventMetaData);
        }
Ejemplo n.º 3
0
        public void Handle(CommentLikedEvent @event)
        {
            var comment = this.Comments.First(x => x.Id == @event.Id);

            comment.CommentLiked(applyEvent: false);
        }