Example #1
0
 public void Create(CommentPublishedEvent @event)
 {
     this.Id           = @event.Id;
     this.Content      = @event.Content;
     this.CreationDate = @event.CreationDate;
     this.AuthorId     = @event.AuthorId;
 }
Example #2
0
        public async Task <IActionResult> PublishComment(PublishCommentModel newComment)
        {
            var command       = new PublishCommentCommand(newComment.PostID, newComment.CommentText, User.GetIdentifier());
            var commandResult = await _dispatcher.Send(command);

            if (commandResult.IsSuccess)
            {
                var newCommentNotification = new CommentPublishedEvent(
                    User.Identity.Name,
                    Url.Action("Profile", "Account", new { id = User.Identity.Name }),
                    newComment.PostID,
                    Url.Action("Detail", "Post", new { id = newComment.PostID })
                    );

                await _dispatcher.Publish(newCommentNotification);
            }
            var commentsQuery = new PostCommentsQuery(newComment.PostID);
            var comments      = await _dispatcher.Send(commentsQuery);

            return(PartialView("_CommentsPartial", comments));
        }