TenantId added to all events in main flow
This commit is contained in:
parent
24949c2baf
commit
f5f871fc94
@ -49,6 +49,8 @@
|
|||||||
? (IntegrationEvent)new OrderStockRejectedIntegrationEvent(@event.OrderId, confirmedOrderStockItems)
|
? (IntegrationEvent)new OrderStockRejectedIntegrationEvent(@event.OrderId, confirmedOrderStockItems)
|
||||||
: new OrderStockConfirmedIntegrationEvent(@event.OrderId);
|
: new OrderStockConfirmedIntegrationEvent(@event.OrderId);
|
||||||
|
|
||||||
|
confirmedIntegrationEvent.TenantId = @event.TenantId;
|
||||||
|
|
||||||
await _catalogIntegrationEventService.SaveEventAndCatalogContextChangesAsync(confirmedIntegrationEvent);
|
await _catalogIntegrationEventService.SaveEventAndCatalogContextChangesAsync(confirmedIntegrationEvent);
|
||||||
await _catalogIntegrationEventService.PublishThroughEventBusAsync(confirmedIntegrationEvent);
|
await _catalogIntegrationEventService.PublishThroughEventBusAsync(confirmedIntegrationEvent);
|
||||||
|
|
||||||
|
@ -12,10 +12,13 @@ namespace Ordering.API.Application.Commands
|
|||||||
|
|
||||||
[DataMember]
|
[DataMember]
|
||||||
public int OrderNumber { get; private set; }
|
public int OrderNumber { get; private set; }
|
||||||
|
[DataMember]
|
||||||
|
public int TenantId { get; private set; }
|
||||||
|
|
||||||
public SetStockConfirmedOrderStatusCommand(int orderNumber)
|
public SetStockConfirmedOrderStatusCommand(int orderNumber, int tenantId)
|
||||||
{
|
{
|
||||||
OrderNumber = orderNumber;
|
OrderNumber = orderNumber;
|
||||||
|
TenantId = tenantId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -35,7 +35,7 @@ namespace Ordering.API.Application.Commands
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
orderToUpdate.SetStockConfirmedStatus();
|
orderToUpdate.SetStockConfirmedStatus(command.TenantId);
|
||||||
return await _orderRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken);
|
return await _orderRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,8 @@
|
|||||||
var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString());
|
var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString());
|
||||||
|
|
||||||
var orderStatusChangedToStockConfirmedIntegrationEvent = new OrderStatusChangedToStockConfirmedIntegrationEvent(order.Id, order.OrderStatus.Name, buyer.Name);
|
var orderStatusChangedToStockConfirmedIntegrationEvent = new OrderStatusChangedToStockConfirmedIntegrationEvent(order.Id, order.OrderStatus.Name, buyer.Name);
|
||||||
|
orderStatusChangedToStockConfirmedIntegrationEvent.TenantId =
|
||||||
|
orderStatusChangedToStockConfirmedDomainEvent.TenantId;
|
||||||
await _orderingIntegrationEventService.AddAndSaveEventAsync(orderStatusChangedToStockConfirmedIntegrationEvent);
|
await _orderingIntegrationEventService.AddAndSaveEventAsync(orderStatusChangedToStockConfirmedIntegrationEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
{
|
{
|
||||||
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
|
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
|
||||||
|
|
||||||
var command = new SetStockConfirmedOrderStatusCommand(@event.OrderId);
|
var command = new SetStockConfirmedOrderStatusCommand(@event.OrderId, @event.TenantId);
|
||||||
|
|
||||||
_logger.LogInformation(
|
_logger.LogInformation(
|
||||||
"----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})",
|
"----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})",
|
||||||
|
@ -114,11 +114,11 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetStockConfirmedStatus()
|
public void SetStockConfirmedStatus(int tenantId)
|
||||||
{
|
{
|
||||||
if (_orderStatusId == OrderStatus.AwaitingValidation.Id)
|
if (_orderStatusId == OrderStatus.AwaitingValidation.Id)
|
||||||
{
|
{
|
||||||
AddDomainEvent(new OrderStatusChangedToStockConfirmedDomainEvent(Id));
|
AddDomainEvent(new OrderStatusChangedToStockConfirmedDomainEvent(Id).withTenantId(tenantId));
|
||||||
|
|
||||||
_orderStatusId = OrderStatus.StockConfirmed.Id;
|
_orderStatusId = OrderStatus.StockConfirmed.Id;
|
||||||
_description = "All the items were confirmed with available stock.";
|
_description = "All the items were confirmed with available stock.";
|
||||||
|
@ -9,8 +9,15 @@
|
|||||||
: INotification
|
: INotification
|
||||||
{
|
{
|
||||||
public int OrderId { get; }
|
public int OrderId { get; }
|
||||||
|
public int TenantId { get; set; }
|
||||||
|
|
||||||
public OrderStatusChangedToStockConfirmedDomainEvent(int orderId)
|
public OrderStatusChangedToStockConfirmedDomainEvent(int orderId)
|
||||||
=> OrderId = orderId;
|
=> OrderId = orderId;
|
||||||
|
|
||||||
|
public OrderStatusChangedToStockConfirmedDomainEvent withTenantId(int tenantId)
|
||||||
|
{
|
||||||
|
this.TenantId = tenantId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,6 @@
|
|||||||
namespace Payment.API.IntegrationEvents.EventHandling
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Extensions;
|
||||||
|
|
||||||
|
namespace Payment.API.IntegrationEvents.EventHandling
|
||||||
{
|
{
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
@ -50,6 +52,7 @@
|
|||||||
orderPaymentIntegrationEvent = new OrderPaymentFailedIntegrationEvent(@event.OrderId);
|
orderPaymentIntegrationEvent = new OrderPaymentFailedIntegrationEvent(@event.OrderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
orderPaymentIntegrationEvent.TenantId = @event.TenantId;
|
||||||
_logger.LogInformation("----- Publishing integration event: {IntegrationEventId} from {AppName} - ({@IntegrationEvent})", orderPaymentIntegrationEvent.Id, Program.AppName, orderPaymentIntegrationEvent);
|
_logger.LogInformation("----- Publishing integration event: {IntegrationEventId} from {AppName} - ({@IntegrationEvent})", orderPaymentIntegrationEvent.Id, Program.AppName, orderPaymentIntegrationEvent);
|
||||||
|
|
||||||
_eventBus.Publish(orderPaymentIntegrationEvent);
|
_eventBus.Publish(orderPaymentIntegrationEvent);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user