|
1 |
| -using System; |
2 |
| -using MediatR; |
| 1 | +using MediatR; |
3 | 2 | using Polly;
|
| 3 | +using Prometheus; |
4 | 4 | using Shared.DomainDrivenDesign.EventSourcing;
|
| 5 | +using Shared.EventStore.Aggregate; |
5 | 6 | using Shared.EventStore.EventHandling;
|
| 7 | +using Shared.Exceptions; |
| 8 | +using Shared.Logger; |
| 9 | +using Shared.ValueObjects; |
6 | 10 | using SimpleResults;
|
| 11 | +using System; |
7 | 12 | using System.Diagnostics;
|
8 | 13 | using System.IO;
|
9 | 14 | using System.Net.Http;
|
10 | 15 | using System.Threading;
|
11 | 16 | using System.Threading.Tasks;
|
12 |
| -using Prometheus; |
13 |
| -using Shared.Logger; |
14 | 17 | using TransactionProcessor.BusinessLogic.Common;
|
15 | 18 | using TransactionProcessor.BusinessLogic.Requests;
|
16 | 19 | using TransactionProcessor.BusinessLogic.Services;
|
17 | 20 | using TransactionProcessor.DomainEvents;
|
18 |
| -using Shared.EventStore.Aggregate; |
19 |
| -using Shared.ValueObjects; |
20 | 21 |
|
21 | 22 | namespace TransactionProcessor.BusinessLogic.EventHandling
|
22 | 23 | {
|
@@ -144,12 +145,32 @@ private async Task<Result> HandleSpecificDomainEvent(MerchantDomainEvents.Withdr
|
144 | 145 | private async Task<Result> HandleSpecificDomainEvent(SettlementDomainEvents.MerchantFeeSettledEvent domainEvent,
|
145 | 146 | CancellationToken cancellationToken)
|
146 | 147 | {
|
147 |
| - MerchantStatementCommands.AddSettledFeeToMerchantStatementCommand command = new(domainEvent.EstateId, domainEvent.MerchantId, domainEvent.FeeCalculatedDateTime, |
148 |
| - PositiveMoney.Create(Money.Create(domainEvent.CalculatedValue)), domainEvent.TransactionId, domainEvent.FeeId); |
| 148 | + IAsyncPolicy<Result> retryPolicy = PolicyFactory.CreatePolicy(policyTag: "MerchantStatementDomainEventHandler - HandleSpecificDomainEvent<SettlementDomainEvents.MerchantFeeSettledEvent>"); |
| 149 | + |
| 150 | + try |
| 151 | + { |
| 152 | + return await PolicyFactory.ExecuteWithPolicyAsync(async () => |
| 153 | + { |
| 154 | + MerchantStatementCommands.AddSettledFeeToMerchantStatementCommand command = new(domainEvent.EstateId, domainEvent.MerchantId, domainEvent.FeeCalculatedDateTime, |
| 155 | + PositiveMoney.Create(Money.Create(domainEvent.CalculatedValue)), domainEvent.TransactionId, domainEvent.FeeId); |
| 156 | + |
| 157 | + Result result = await this.Mediator.Send(command, cancellationToken); |
| 158 | + return result; |
| 159 | + |
| 160 | + }, retryPolicy, "MerchantStatementDomainEventHandler - HandleSpecificDomainEvent<SettlementDomainEvents.MerchantFeeSettledEvent>"); |
| 161 | + } |
| 162 | + catch (Exception ex) |
| 163 | + { |
| 164 | + return Result.Failure(ex.GetExceptionMessages()); |
| 165 | + } |
| 166 | + //MerchantStatementCommands.AddSettledFeeToMerchantStatementCommand command = new(domainEvent.EstateId, domainEvent.MerchantId, domainEvent.FeeCalculatedDateTime, |
| 167 | + // PositiveMoney.Create(Money.Create(domainEvent.CalculatedValue)), domainEvent.TransactionId, domainEvent.FeeId); |
| 168 | + |
| 169 | + ////return await this.Mediator.Send(command, cancellationToken); |
| 170 | + //Result result = await this.Mediator.Send(command, cancellationToken); |
| 171 | + //return result; |
| 172 | + |
149 | 173 |
|
150 |
| - //return await this.Mediator.Send(command, cancellationToken); |
151 |
| - Result result = await this.Mediator.Send(command, cancellationToken); |
152 |
| - return result; |
153 | 174 | }
|
154 | 175 |
|
155 | 176 | #endregion
|
|
0 commit comments