protected override async Task Handle(UpdateBlogUrlCommand command, CancellationToken cancellationToken) { Blog blog = await blogReadOnlyRepository.GetBlog(command.Id); blog.UpdateUrl(Url.Create(command.Url)); await bus.Publish(blog.GetEvents(), command.Header); }
public async Task Handle(EnableBlogCommand command) { Blog blog = await blogReadOnlyRepository.GetBlog(command.Id); blog.Enable(); await bus.Publish(blog.GetEvents(), command.Header); }
public async Task Handle(UpdateBlogUrlCommand command) { Blog blog = await blogReadOnlyRepository.GetBlog(command.Id); blog.UpdateUrl(Url.Create(command.Url)); await bus.Publish(blog.GetEvents(), command.Header); }
protected override async Task Handle(EnableBlogCommand request, CancellationToken cancellationToken) { Blog blog = await blogReadOnlyRepository.GetBlog(request.Id); blog.Enable(); await bus.Publish(blog.GetEvents(), request.Header); }
protected override async Task Handle(DisableBlogCommand command, CancellationToken cancellationToken) { Blog blog = await blogReadOnlyRepository.GetBlog(command.Id); blog.Disable(); await bus.Publish(blog.GetEvents(), command.Header); }
protected override void Handle(BlogEnabledDomainEvent domainEvent) { Blog blog = blogReadOnlyRepository.GetBlog(domainEvent.AggregateRootId).Result; if (blog.Version != domainEvent.Version) { throw new TransactionConflictException(blog, domainEvent); } blog.Apply(domainEvent); blogWriteOnlyRepository.UpdateBlog(blog).Wait(); }
public async Task <Guid> Handle(CreatePostCommand command) { Blog blog = await blogReadOnlyRepository.GetBlog(command.BlogId); Post post = Post.Create(); post.Start(command.BlogId, blog.Version); post.UpdateContent(Title.Create(command.Title), Content.Create(command.Content)); await bus.Publish(post.GetEvents(), command.Header); return(post.Id); }
public void Handle(PostCreatedDomainEvent domainEvent) { Blog blog = blogReadOnlyRepository.GetBlog(domainEvent.BlogId).Result; if (blog.Version != blog.Version) { throw new TransactionConflictException(blog, domainEvent); } Post post = Post.Create(); post.Apply(domainEvent); postWriteOnlyRepository.AddPost(post).Wait(); blog.Apply(domainEvent); blogWriteOnlyRepository.UpdateBlog(blog).Wait(); }
public async Task <IActionResult> Get(Guid id) { var blog = await blogQueries.GetBlog(id); return(Ok(blog)); }