Skip to content

Commit 8b80eea

Browse files
committed
minor changes
1 parent 3556a5d commit 8b80eea

18 files changed

Lines changed: 67 additions & 114 deletions

File tree

src/Services/Basket/Basket.API/Startup.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,6 @@ protected virtual void ConfigureAuth(IApplicationBuilder app)
165165

166166
protected virtual void ConfigureEventBus(IApplicationBuilder app)
167167
{
168-
var catalogPriceHandler = app.ApplicationServices
169-
.GetService<IIntegrationEventHandler<ProductPriceChangedIntegrationEvent>>();
170-
171-
var orderStartedHandler = app.ApplicationServices
172-
.GetService<IIntegrationEventHandler<OrderStartedIntegrationEvent>>();
173-
174168
var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();
175169

176170
eventBus.Subscribe<ProductPriceChangedIntegrationEvent, ProductPriceChangedIntegrationEventHandler>();

src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/DecrementOrderStockCommandMsgHandler.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
using BuildingBlocks.EventBus.Abstractions;
44
using System.Threading.Tasks;
55
using Infrastructure;
6-
using global::Catalog.API.Infrastructure.Exceptions;
7-
using global::Catalog.API.IntegrationEvents;
8-
using Model;
96
using Commands;
107

118
public class DecrementOrderStockCommandMsgHandler : IIntegrationEventHandler<DecrementOrderStockCommandMsg>

src/Services/Catalog/Catalog.API/Startup.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
121121
return new DefaultRabbitMQPersistentConnection(factory, logger);
122122
});
123123

124-
services.AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>();
125-
services.AddSingleton<IEventBus, EventBusRabbitMQ>();
126-
services.AddTransient<IIntegrationEventHandler<ConfirmOrderStockCommandMsg>, ConfirmOrderStockCommandMsgHandler>();
127-
services.AddTransient<IIntegrationEventHandler<DecrementOrderStockCommandMsg>, DecrementOrderStockCommandMsgHandler>();
124+
RegisterServiceBus(services);
128125

129126
var container = new ContainerBuilder();
130127
container.Populate(services);
@@ -188,6 +185,18 @@ private void WaitForSqlAvailability(CatalogContext ctx, ILoggerFactory loggerFac
188185
}
189186
}
190187

188+
private void RegisterServiceBus(IServiceCollection services)
189+
{
190+
services.AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>();
191+
services.AddSingleton<IEventBus, EventBusRabbitMQ>();
192+
193+
services.AddTransient<IIntegrationEventHandler<ConfirmOrderStockCommandMsg>,
194+
ConfirmOrderStockCommandMsgHandler>();
195+
services.AddTransient<IIntegrationEventHandler<DecrementOrderStockCommandMsg>,
196+
DecrementOrderStockCommandMsgHandler>();
197+
198+
}
199+
191200
private void ConfigureEventBus(IApplicationBuilder app)
192201
{
193202
var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();

src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public async Task<bool> Handle(CreateOrderCommand message)
4343
// make sure that consistency is preserved across the whole aggregate
4444
var address = new Address(message.Street, message.City, message.State, message.Country, message.ZipCode);
4545
var order = new Order(message.UserId, address, message.CardTypeId, message.CardNumber, message.CardSecurityNumber, message.CardHolderName, message.CardExpiration);
46-
order.SetSubmitedStatus();
46+
4747
foreach (var item in message.OrderItems)
4848
{
4949
order.AddOrderItem(item.ProductId, item.ProductName, item.UnitPrice, item.Discount, item.PictureUrl, item.Units);

src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderGracePeriodConfirmed/OrderStatusChangedToAwaitingValidationDomainEventHandler.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ public OrderStatusChangedToAwaitingValidationDomainEventHandler(
2828

2929
public async Task Handle(OrderStatusChangedToAwaitingValidationDomainEvent orderStatusChangedToAwaitingValidationDomainEvent)
3030
{
31-
await _orderRepository.UnitOfWork.SaveEntitiesAsync();
32-
3331
_logger.CreateLogger(nameof(OrderStatusChangedToAwaitingValidationDomainEvent))
3432
.LogTrace($"Order with Id: {orderStatusChangedToAwaitingValidationDomainEvent.OrderId} has been successfully updated with " +
3533
$"a status order id: {OrderStatus.AwaitingValidation.Id}");

src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderPaid/OrderStatusChangedToPaidDomainEventHandler.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ public OrderStatusChangedToPaidDomainEventHandler(
2828

2929
public async Task Handle(OrderStatusChangedToPaidDomainEvent orderStatusChangedToPaidDomainEvent)
3030
{
31-
await _orderRepository.UnitOfWork.SaveEntitiesAsync();
32-
3331
_logger.CreateLogger(nameof(OrderStatusChangedToPaidDomainEventHandler))
3432
.LogTrace($"Order with Id: {orderStatusChangedToPaidDomainEvent.OrderId} has been successfully updated with " +
3533
$"a status order id: {OrderStatus.Paid.Id}");

src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStockConfirmed/OrderStatusChangedToStockConfirmedDomainEventHandler.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ public OrderStatusChangedToStockConfirmedDomainEventHandler(
2727

2828
public async Task Handle(OrderStatusChangedToStockConfirmedDomainEvent orderStatusChangedToStockConfirmedDomainEvent)
2929
{
30-
await _orderRepository.UnitOfWork.SaveEntitiesAsync();
31-
3230
_logger.CreateLogger(nameof(OrderStatusChangedToStockConfirmedDomainEventHandler))
3331
.LogTrace($"Order with Id: {orderStatusChangedToStockConfirmedDomainEvent.OrderId} has been successfully updated with " +
3432
$"a status order id: {OrderStatus.StockConfirmed.Id}");

src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentFailedIntegrationEventHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public async Task Handle(OrderPaymentFailedIntegrationEvent @event)
2121

2222
orderToUpdate.SetCancelledStatus();
2323

24-
await _orderRepository.UnitOfWork.SaveChangesAsync();
24+
await _orderRepository.UnitOfWork.SaveEntitiesAsync();
2525
}
2626
}
2727
}

src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentSuccededIntegrationEventHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public async Task Handle(OrderPaymentSuccededIntegrationEvent @event)
2121

2222
orderToUpdate.SetPaidStatus();
2323

24-
await _orderRepository.UnitOfWork.SaveChangesAsync();
24+
await _orderRepository.UnitOfWork.SaveEntitiesAsync();
2525
}
2626
}
2727
}

src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public async Task Handle(OrderStockConfirmedIntegrationEvent @event)
2121

2222
orderToUpdate.SetStockConfirmedStatus();
2323

24-
await _orderRepository.UnitOfWork.SaveChangesAsync();
24+
await _orderRepository.UnitOfWork.SaveEntitiesAsync();
2525
}
2626
}
2727
}

0 commit comments

Comments
 (0)