public void Create(CommentPublishedEvent @event) { this.Id = @event.Id; this.Content = @event.Content; this.CreationDate = @event.CreationDate; this.AuthorId = @event.AuthorId; }
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)); }