public void ApproveComment(Guid commentId) { var @event = new CommentApproved(commentId); Apply(@event); AppendEvent(@event); }
public void Handle(CommentApproved @event) { var collection = CreateCollection(); var find = Query.EQ("_id", @event.CommentId); collection.Remove(find, RemoveFlags.Single); }
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); }
public void Apply(CommentApproved @event) { var comment = _comments.First(x => x.Id == @event.CommentId); comment.Approved = true; }