Renaming.
This commit is contained in:
parent
f502c2388f
commit
254d479582
@ -8,15 +8,15 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Basket.API.Events
|
namespace Basket.API.Events
|
||||||
{
|
{
|
||||||
public class CatalogPriceChangedHandler : IIntegrationEventHandler<CatalogPriceChanged>
|
public class ProductPriceChangedHandler : IIntegrationEventHandler<ProductPriceChanged>
|
||||||
{
|
{
|
||||||
private readonly IBasketRepository _repository;
|
private readonly IBasketRepository _repository;
|
||||||
public CatalogPriceChangedHandler(IBasketRepository repository)
|
public ProductPriceChangedHandler(IBasketRepository repository)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Handle(CatalogPriceChanged @event)
|
public async Task Handle(ProductPriceChanged @event)
|
||||||
{
|
{
|
||||||
var userIds = await _repository.GetUsers();
|
var userIds = await _repository.GetUsers();
|
||||||
foreach (var id in userIds)
|
foreach (var id in userIds)
|
||||||
|
@ -79,16 +79,16 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
|
|||||||
});
|
});
|
||||||
|
|
||||||
services.AddTransient<IBasketRepository, RedisBasketRepository>();
|
services.AddTransient<IBasketRepository, RedisBasketRepository>();
|
||||||
services.AddTransient<IIntegrationEventHandler<CatalogPriceChanged>, CatalogPriceChangedHandler>();
|
services.AddTransient<IIntegrationEventHandler<ProductPriceChanged>, ProductPriceChangedHandler>();
|
||||||
|
|
||||||
var serviceProvider = services.BuildServiceProvider();
|
var serviceProvider = services.BuildServiceProvider();
|
||||||
var configuration = serviceProvider.GetRequiredService<IOptionsSnapshot<BasketSettings>>().Value;
|
var configuration = serviceProvider.GetRequiredService<IOptionsSnapshot<BasketSettings>>().Value;
|
||||||
var eventBus = new EventBus(configuration.EventBusConnection);
|
var eventBus = new EventBusRabbitMQ(configuration.EventBusConnection);
|
||||||
services.AddSingleton<IEventBus>(eventBus);
|
services.AddSingleton<IEventBus>(eventBus);
|
||||||
|
|
||||||
|
|
||||||
var catalogPriceHandler = serviceProvider.GetService<IIntegrationEventHandler<CatalogPriceChanged>>();
|
var catalogPriceHandler = serviceProvider.GetService<IIntegrationEventHandler<ProductPriceChanged>>();
|
||||||
eventBus.Subscribe<CatalogPriceChanged>(catalogPriceHandler);
|
eventBus.Subscribe<ProductPriceChanged>(catalogPriceHandler);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
|||||||
_context.CatalogItems.Update(item);
|
_context.CatalogItems.Update(item);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var @event = new CatalogPriceChanged(item.Id, item.Price, oldPrice);
|
var @event = new ProductPriceChanged(item.Id, item.Price, oldPrice);
|
||||||
await ProcessEventAsync(@event);
|
await ProcessEventAsync(@event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
|
|
||||||
var serviceProvider = services.BuildServiceProvider();
|
var serviceProvider = services.BuildServiceProvider();
|
||||||
var configuration = serviceProvider.GetRequiredService<IOptionsSnapshot<Settings>>().Value;
|
var configuration = serviceProvider.GetRequiredService<IOptionsSnapshot<Settings>>().Value;
|
||||||
services.AddSingleton<IEventBus>(new EventBus(configuration.EventBusConnection));
|
services.AddSingleton<IEventBus>(new EventBusRabbitMQ(configuration.EventBusConnection));
|
||||||
|
|
||||||
services.AddMvc();
|
services.AddMvc();
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ using System.Text;
|
|||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Common.Infrastructure.Catalog
|
namespace Microsoft.eShopOnContainers.Services.Common.Infrastructure.Catalog
|
||||||
{
|
{
|
||||||
public class CatalogPriceChanged : IntegrationEventBase
|
public class ProductPriceChanged : IntegrationEventBase
|
||||||
{
|
{
|
||||||
public int ItemId { get; private set; }
|
public int ItemId { get; private set; }
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ namespace Microsoft.eShopOnContainers.Services.Common.Infrastructure.Catalog
|
|||||||
|
|
||||||
public decimal OldPrice { get; set; }
|
public decimal OldPrice { get; set; }
|
||||||
|
|
||||||
public CatalogPriceChanged(int itemId, decimal newPrice, decimal oldPrice)
|
public ProductPriceChanged(int itemId, decimal newPrice, decimal oldPrice)
|
||||||
{
|
{
|
||||||
ItemId = itemId;
|
ItemId = itemId;
|
||||||
NewPrice = newPrice;
|
NewPrice = newPrice;
|
@ -13,7 +13,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Common.Infrastructure
|
namespace Microsoft.eShopOnContainers.Services.Common.Infrastructure
|
||||||
{
|
{
|
||||||
public class EventBus : IEventBus
|
public class EventBusRabbitMQ : IEventBus
|
||||||
{
|
{
|
||||||
private readonly string _brokerName = "event_bus";
|
private readonly string _brokerName = "event_bus";
|
||||||
private readonly string _connectionString;
|
private readonly string _connectionString;
|
||||||
@ -24,7 +24,7 @@ namespace Microsoft.eShopOnContainers.Services.Common.Infrastructure
|
|||||||
private string _queueName;
|
private string _queueName;
|
||||||
|
|
||||||
|
|
||||||
public EventBus(string connectionString)
|
public EventBusRabbitMQ(string connectionString)
|
||||||
{
|
{
|
||||||
_connectionString = connectionString;
|
_connectionString = connectionString;
|
||||||
_handlers = new Dictionary<string, List<IIntegrationEventHandler>>();
|
_handlers = new Dictionary<string, List<IIntegrationEventHandler>>();
|
Loading…
x
Reference in New Issue
Block a user