You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Tiobon.Web/Blog.Core.Extensions/EventHandling/BlogQueryIntegrationEventHa...

33 lines
1.2 KiB

using Blog.Core.Common;
using Blog.Core.EventBus.EventHandling;
using Blog.Core.IServices;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;
namespace Blog.Core.EventBus
{
public class BlogQueryIntegrationEventHandler : IIntegrationEventHandler<BlogQueryIntegrationEvent>
{
private readonly IBlogArticleServices _blogArticleServices;
private readonly ILogger<BlogQueryIntegrationEventHandler> _logger;
public BlogQueryIntegrationEventHandler(
IBlogArticleServices blogArticleServices,
ILogger<BlogQueryIntegrationEventHandler> logger)
{
_blogArticleServices = blogArticleServices;
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public async Task Handle(BlogQueryIntegrationEvent @event)
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, "Blog.Core", @event);
ConsoleHelper.WriteSuccessLine($"----- Handling integration event: {@event.Id} at Blog.Core - ({@event})");
await _blogArticleServices.QueryById(@event.BlogId.ToString());
}
}
}