|
6 | 6 | using Microsoft.Extensions.Logging; |
7 | 7 | using Ordering.API.Application.IntegrationEvents.Events; |
8 | 8 | using Serilog.Context; |
| 9 | +using Microsoft.eShopOnContainers.Services.Ordering.API; |
9 | 10 |
|
10 | 11 | namespace Ordering.API.Application.IntegrationEvents.EventHandling |
11 | 12 | { |
@@ -35,34 +36,38 @@ public async Task Handle(UserCheckoutAcceptedIntegrationEvent eventMsg) |
35 | 36 | { |
36 | 37 | using (LogContext.PushProperty("IntegrationEventId", eventMsg.Id)) |
37 | 38 | { |
38 | | - _logger.LogInformation("----- UserCheckoutAcceptedIntegrationEventHandler - Handling integration event: {IntegrationEventId} ({@IntegrationEvent})", eventMsg.Id, eventMsg); |
| 39 | + _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppShortName} - ({@IntegrationEvent})", eventMsg.Id, Program.AppShortName, eventMsg); |
39 | 40 |
|
40 | 41 | var result = false; |
41 | 42 |
|
42 | 43 | if (eventMsg.RequestId != Guid.Empty) |
43 | 44 | { |
44 | | - var createOrderCommand = new CreateOrderCommand(eventMsg.Basket.Items, eventMsg.UserId, eventMsg.UserName, eventMsg.City, eventMsg.Street, |
45 | | - eventMsg.State, eventMsg.Country, eventMsg.ZipCode, |
46 | | - eventMsg.CardNumber, eventMsg.CardHolderName, eventMsg.CardExpiration, |
47 | | - eventMsg.CardSecurityNumber, eventMsg.CardTypeId); |
| 45 | + using (LogContext.PushProperty("IdentifiedCommandId", eventMsg.RequestId)) |
| 46 | + { |
| 47 | + var createOrderCommand = new CreateOrderCommand(eventMsg.Basket.Items, eventMsg.UserId, eventMsg.UserName, eventMsg.City, eventMsg.Street, |
| 48 | + eventMsg.State, eventMsg.Country, eventMsg.ZipCode, |
| 49 | + eventMsg.CardNumber, eventMsg.CardHolderName, eventMsg.CardExpiration, |
| 50 | + eventMsg.CardSecurityNumber, eventMsg.CardTypeId); |
48 | 51 |
|
49 | | - _logger.LogInformation("----- UserCheckoutAcceptedIntegrationEventHandler - CreateOrderCommand: {@CreateOrderCommand}", createOrderCommand); |
| 52 | + var requestCreateOrder = new IdentifiedCommand<CreateOrderCommand, bool>(createOrderCommand, eventMsg.RequestId); |
50 | 53 |
|
51 | | - var requestCreateOrder = new IdentifiedCommand<CreateOrderCommand, bool>(createOrderCommand, eventMsg.RequestId); |
52 | | - result = await _mediator.Send(requestCreateOrder); |
| 54 | + _logger.LogInformation("----- IdentifiedCreateOrderCommand: {@IdentifiedCreateOrderCommand}", requestCreateOrder); |
53 | 55 |
|
54 | | - if (result) |
55 | | - { |
56 | | - _logger.LogInformation("----- UserCheckoutAcceptedIntegrationEventHandler - CreateOrderCommand suceeded - RequestId: {RequestId}", eventMsg.RequestId); |
57 | | - } |
58 | | - else |
59 | | - { |
60 | | - _logger.LogWarning("----- UserCheckoutAcceptedIntegrationEventHandler - CreateOrderCommand failed - RequestId: {RequestId}", eventMsg.RequestId); |
| 56 | + result = await _mediator.Send(requestCreateOrder); |
| 57 | + |
| 58 | + if (result) |
| 59 | + { |
| 60 | + _logger.LogInformation("----- CreateOrderCommand suceeded - RequestId: {RequestId}", eventMsg.RequestId); |
| 61 | + } |
| 62 | + else |
| 63 | + { |
| 64 | + _logger.LogWarning("----- CreateOrderCommand failed - RequestId: {RequestId}", eventMsg.RequestId); |
| 65 | + } |
61 | 66 | } |
62 | 67 | } |
63 | 68 | else |
64 | 69 | { |
65 | | - _logger.LogWarning("----- UserCheckoutAcceptedIntegrationEventHandler - Invalid IntegrationEvent - RequestId is missing}"); |
| 70 | + _logger.LogWarning("----- Invalid IntegrationEvent - RequestId is missing - {@IntegrationEvent}", eventMsg); |
66 | 71 | } |
67 | 72 | } |
68 | 73 | } |
|
0 commit comments