From 00f7226f30011693969a6f21a94d0e4d589180d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Tom=C3=A1s?= Date: Wed, 5 Apr 2017 11:07:26 +0200 Subject: [PATCH] Rename OrderingIntegrationEvent service methods Remove clean basket instruction from SPA client --- ...rWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs | 4 ++-- .../IntegrationEvents/IOrderingIntegrationEventService.cs | 4 ++-- .../IntegrationEvents/OrderingIntegrationEventService.cs | 4 ++-- .../modules/orders/orders-new/orders-new.component.ts | 7 ++----- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/BuyerAndPaymentMethodVerified/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/BuyerAndPaymentMethodVerified/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs index dd469ae78..ce55fd0c9 100644 --- a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/BuyerAndPaymentMethodVerified/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/BuyerAndPaymentMethodVerified/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs @@ -39,11 +39,11 @@ namespace Ordering.API.Application.DomainEventHandlers.BuyerAndPaymentMethodVeri // Using a local transaction to achieve atomicity between original Ordering database operation and // the IntegrationEventLog. Only saving event if order has been successfully persisted to db await _orderingIntegrationEventService - .SaveEventAsync(orderStartedIntegrationEvent); + .SaveEventAndOrderingContextChangesAsync(orderStartedIntegrationEvent); // Publish ordering integration event and mark it as published await _orderingIntegrationEventService - .PublishAsync(orderStartedIntegrationEvent); + .PublishThroughEventBusAsync(orderStartedIntegrationEvent); _logger.CreateLogger(nameof(UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler)) .LogTrace($"Order with Id: {buyerPaymentMethodVerifiedEvent.OrderId} has been successfully updated with a payment method id: { buyerPaymentMethodVerifiedEvent.Payment.Id }"); diff --git a/src/Services/Ordering/Ordering.API/IntegrationEvents/IOrderingIntegrationEventService.cs b/src/Services/Ordering/Ordering.API/IntegrationEvents/IOrderingIntegrationEventService.cs index 93ea518ba..6538afbfd 100644 --- a/src/Services/Ordering/Ordering.API/IntegrationEvents/IOrderingIntegrationEventService.cs +++ b/src/Services/Ordering/Ordering.API/IntegrationEvents/IOrderingIntegrationEventService.cs @@ -8,7 +8,7 @@ namespace Ordering.API.IntegrationEvents { public interface IOrderingIntegrationEventService { - Task SaveEventAsync(IntegrationEvent evt); - Task PublishAsync(IntegrationEvent evt); + Task SaveEventAndOrderingContextChangesAsync(IntegrationEvent evt); + Task PublishThroughEventBusAsync(IntegrationEvent evt); } } diff --git a/src/Services/Ordering/Ordering.API/IntegrationEvents/OrderingIntegrationEventService.cs b/src/Services/Ordering/Ordering.API/IntegrationEvents/OrderingIntegrationEventService.cs index b05ea44d0..810c07bc9 100644 --- a/src/Services/Ordering/Ordering.API/IntegrationEvents/OrderingIntegrationEventService.cs +++ b/src/Services/Ordering/Ordering.API/IntegrationEvents/OrderingIntegrationEventService.cs @@ -28,13 +28,13 @@ namespace Ordering.API.IntegrationEvents _eventLogService = _integrationEventLogServiceFactory(_orderingContext.Database.GetDbConnection()); } - public async Task PublishAsync(IntegrationEvent evt) + public async Task PublishThroughEventBusAsync(IntegrationEvent evt) { _eventBus.Publish(evt); await _eventLogService.MarkEventAsPublishedAsync(evt); } - public async Task SaveEventAsync(IntegrationEvent evt) + public async Task SaveEventAndOrderingContextChangesAsync(IntegrationEvent evt) { //Use of an EF Core resiliency strategy when using multiple DbContexts within an explicit BeginTransaction(): //See: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency diff --git a/src/Web/WebSPA/Client/modules/orders/orders-new/orders-new.component.ts b/src/Web/WebSPA/Client/modules/orders/orders-new/orders-new.component.ts index 72114631f..8f8a10eb0 100644 --- a/src/Web/WebSPA/Client/modules/orders/orders-new/orders-new.component.ts +++ b/src/Web/WebSPA/Client/modules/orders/orders-new/orders-new.component.ts @@ -18,7 +18,7 @@ export class OrdersNewComponent implements OnInit { private errorReceived: Boolean; private order: IOrder; - constructor(private service: OrdersService, fb: FormBuilder, private router: Router, private basketEvents: BasketWrapperService) { + constructor(private service: OrdersService, fb: FormBuilder, private router: Router) { // Obtain user profile information this.order = service.mapBasketAndIdentityInfoNewOrder(); this.newOrderForm = fb.group({ @@ -54,10 +54,7 @@ export class OrdersNewComponent implements OnInit { return Observable.throw(errMessage); }) .subscribe(res => { - // this will emit an observable. Basket service is subscribed to this observable, and will react deleting the basket for the current user. - this.basketEvents.orderCreated(); - - this.router.navigate(['orders']); + this.router.navigate(['orders']); }); this.errorReceived = false; this.isOrderProcessing = true;