Example #1
0
        public void ApproveComment(Guid commentId)
        {
            var @event = new CommentApproved(commentId);

            Apply(@event);

            AppendEvent(@event);
        }
Example #2
0
        public void Handle(CommentApproved @event)
        {
            var collection = CreateCollection();

            var find = Query.EQ("_id", @event.CommentId);

            collection.Remove(find, RemoveFlags.Single);
        }
Example #3
0
        public void Handle(CommentApproved @event)
        {
            var collection = CreateCollection();

            var postsRepository = new PostsRepository(_mongoDatabase);

            var post = postsRepository.Find(@event.AggregateRootId);

            var comment = post.Comments.First(x => x.Id == @event.CommentId);

            var find = Query.EQ("_id", @event.AggregateRootId);

            var update = Update.AddToSet("Comments", comment.ToBsonDocument());

            collection.Update(find, update);
        }
Example #4
0
        public void Apply(CommentApproved @event)
        {
            var comment = _comments.First(x => x.Id == @event.CommentId);

            comment.Approved = true;
        }
Example #5
0
        public void ApproveComment(Guid commentId)
        {
            var @event = new CommentApproved(commentId);

            Apply(@event);

            AppendEvent(@event);
        }
Example #6
0
        public void Apply(CommentApproved @event)
        {
            var comment = _comments.First(x => x.Id == @event.CommentId);

            comment.Approved = true;
        }