Add ConfirmOrderStockIntegrationEventHandler and OrderStockConfirmedIntegrationEvent/OrderStockNotConfirmedIntegrationEvent
This commit is contained in:
parent
00e2634b16
commit
0611978b9a
@ -0,0 +1,33 @@
|
||||
using Catalog.API.IntegrationEvents;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling
|
||||
{
|
||||
using BuildingBlocks.EventBus.Abstractions;
|
||||
using System.Threading.Tasks;
|
||||
using BuildingBlocks.EventBus.Events;
|
||||
using Infrastructure;
|
||||
|
||||
using Events;
|
||||
|
||||
public class ConfirmOrderStockIntegrationEventHandler : IIntegrationEventHandler<ConfirmOrderStockIntegrationEvent>
|
||||
{
|
||||
private readonly CatalogContext _catalogContext;
|
||||
private readonly ICatalogIntegrationEventService _catalogIntegrationEventService;
|
||||
|
||||
public ConfirmOrderStockIntegrationEventHandler(CatalogContext catalogContext,
|
||||
ICatalogIntegrationEventService catalogIntegrationEventService)
|
||||
{
|
||||
_catalogContext = catalogContext;
|
||||
_catalogIntegrationEventService = catalogIntegrationEventService;
|
||||
}
|
||||
|
||||
public async Task Handle(ConfirmOrderStockIntegrationEvent @event)
|
||||
{
|
||||
IntegrationEvent integrationEvent = new OrderStockConfirmedIntegrationEvent(@event.OrderId);
|
||||
|
||||
//TODO: Check the stock products units
|
||||
|
||||
await _catalogIntegrationEventService.PublishThroughEventBusAsync(integrationEvent);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events
|
||||
{
|
||||
using BuildingBlocks.EventBus.Events;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class ConfirmOrderStockIntegrationEvent : IntegrationEvent
|
||||
{
|
||||
public int OrderId { get; }
|
||||
public IEnumerable<OrderStockItem> OrderStockItem { get; }
|
||||
|
||||
public ConfirmOrderStockIntegrationEvent(int orderId,
|
||||
IEnumerable<OrderStockItem> orderStockItem)
|
||||
{
|
||||
OrderId = orderId;
|
||||
OrderStockItem = orderStockItem;
|
||||
}
|
||||
}
|
||||
|
||||
public class OrderStockItem
|
||||
{
|
||||
public int ProductId { get; }
|
||||
public int Units { get; }
|
||||
|
||||
public OrderStockItem(int productId, int units)
|
||||
{
|
||||
ProductId = productId;
|
||||
Units = units;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events
|
||||
{
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||
|
||||
public class OrderStockConfirmedIntegrationEvent : IntegrationEvent
|
||||
{
|
||||
public int OrderId { get; }
|
||||
|
||||
public OrderStockConfirmedIntegrationEvent(int orderId) => OrderId = orderId;
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events
|
||||
{
|
||||
using BuildingBlocks.EventBus.Events;
|
||||
|
||||
public class OrderStockNotConfirmedIntegrationEvent : IntegrationEvent
|
||||
{
|
||||
public int OrderId { get; }
|
||||
|
||||
public IEnumerable<ConfirmedOrderStockItem> OrderStockItem { get; }
|
||||
|
||||
public OrderStockNotConfirmedIntegrationEvent(int orderId,
|
||||
IEnumerable<ConfirmedOrderStockItem> orderStockItem)
|
||||
{
|
||||
OrderId = orderId;
|
||||
OrderStockItem = orderStockItem;
|
||||
}
|
||||
|
||||
public class ConfirmedOrderStockItem
|
||||
{
|
||||
public int ProductId { get; }
|
||||
public int Units { get; }
|
||||
public bool Confirmed { get; }
|
||||
|
||||
public ConfirmedOrderStockItem(int productId, int units, bool confirmed)
|
||||
{
|
||||
ProductId = productId;
|
||||
Units = units;
|
||||
Confirmed = confirmed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -14,6 +14,8 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Model
|
||||
|
||||
public string PictureUri { get; set; }
|
||||
|
||||
public int Stock { get; set; }
|
||||
|
||||
public int CatalogTypeId { get; set; }
|
||||
|
||||
public CatalogType CatalogType { get; set; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user