Browse Source

Rename OrderingIntegrationEvent service methods

Remove clean basket instruction from SPA client
pull/150/head
Ramón Tomás 7 years ago
parent
commit
00f7226f30
4 changed files with 8 additions and 11 deletions
  1. +2
    -2
      src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/BuyerAndPaymentMethodVerified/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs
  2. +2
    -2
      src/Services/Ordering/Ordering.API/IntegrationEvents/IOrderingIntegrationEventService.cs
  3. +2
    -2
      src/Services/Ordering/Ordering.API/IntegrationEvents/OrderingIntegrationEventService.cs
  4. +2
    -5
      src/Web/WebSPA/Client/modules/orders/orders-new/orders-new.component.ts

+ 2
- 2
src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/BuyerAndPaymentMethodVerified/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs View File

@ -39,11 +39,11 @@ namespace Ordering.API.Application.DomainEventHandlers.BuyerAndPaymentMethodVeri
// Using a local transaction to achieve atomicity between original Ordering database operation and // 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 // the IntegrationEventLog. Only saving event if order has been successfully persisted to db
await _orderingIntegrationEventService await _orderingIntegrationEventService
.SaveEventAsync(orderStartedIntegrationEvent);
.SaveEventAndOrderingContextChangesAsync(orderStartedIntegrationEvent);
// Publish ordering integration event and mark it as published // Publish ordering integration event and mark it as published
await _orderingIntegrationEventService await _orderingIntegrationEventService
.PublishAsync(orderStartedIntegrationEvent);
.PublishThroughEventBusAsync(orderStartedIntegrationEvent);
_logger.CreateLogger(nameof(UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler)) _logger.CreateLogger(nameof(UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler))
.LogTrace($"Order with Id: {buyerPaymentMethodVerifiedEvent.OrderId} has been successfully updated with a payment method id: { buyerPaymentMethodVerifiedEvent.Payment.Id }"); .LogTrace($"Order with Id: {buyerPaymentMethodVerifiedEvent.OrderId} has been successfully updated with a payment method id: { buyerPaymentMethodVerifiedEvent.Payment.Id }");


+ 2
- 2
src/Services/Ordering/Ordering.API/IntegrationEvents/IOrderingIntegrationEventService.cs View File

@ -8,7 +8,7 @@ namespace Ordering.API.IntegrationEvents
{ {
public interface IOrderingIntegrationEventService public interface IOrderingIntegrationEventService
{ {
Task SaveEventAsync(IntegrationEvent evt);
Task PublishAsync(IntegrationEvent evt);
Task SaveEventAndOrderingContextChangesAsync(IntegrationEvent evt);
Task PublishThroughEventBusAsync(IntegrationEvent evt);
} }
} }

+ 2
- 2
src/Services/Ordering/Ordering.API/IntegrationEvents/OrderingIntegrationEventService.cs View File

@ -28,13 +28,13 @@ namespace Ordering.API.IntegrationEvents
_eventLogService = _integrationEventLogServiceFactory(_orderingContext.Database.GetDbConnection()); _eventLogService = _integrationEventLogServiceFactory(_orderingContext.Database.GetDbConnection());
} }
public async Task PublishAsync(IntegrationEvent evt)
public async Task PublishThroughEventBusAsync(IntegrationEvent evt)
{ {
_eventBus.Publish(evt); _eventBus.Publish(evt);
await _eventLogService.MarkEventAsPublishedAsync(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(): //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 //See: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency


+ 2
- 5
src/Web/WebSPA/Client/modules/orders/orders-new/orders-new.component.ts View File

@ -18,7 +18,7 @@ export class OrdersNewComponent implements OnInit {
private errorReceived: Boolean; private errorReceived: Boolean;
private order: IOrder; 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 // Obtain user profile information
this.order = service.mapBasketAndIdentityInfoNewOrder(); this.order = service.mapBasketAndIdentityInfoNewOrder();
this.newOrderForm = fb.group({ this.newOrderForm = fb.group({
@ -54,10 +54,7 @@ export class OrdersNewComponent implements OnInit {
return Observable.throw(errMessage); return Observable.throw(errMessage);
}) })
.subscribe(res => { .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.errorReceived = false;
this.isOrderProcessing = true; this.isOrderProcessing = true;


Loading…
Cancel
Save