|
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
| 3 | +using Shared.Logger; |
| 4 | +using Shared.Results; |
3 | 5 | using SimpleResults; |
4 | 6 |
|
5 | 7 | namespace TransactionProcessor.BusinessLogic.OperatorInterfaces.VoucherManagement |
@@ -62,28 +64,30 @@ public async Task<Result<OperatorResponse>> ProcessSaleMessage(Guid transactionI |
62 | 64 | recipientMobile); |
63 | 65 |
|
64 | 66 | Result<IssueVoucherResponse> result= await this.Mediator.Send(command, cancellationToken); |
65 | | - |
66 | | - if (result.IsSuccess) { |
67 | | - // Build the response metadata |
68 | | - Dictionary<String, String> additionalTransactionResponseMetadata = new Dictionary<String, String>(); |
69 | | - additionalTransactionResponseMetadata.Add("VoucherCode", result.Data.VoucherCode); |
70 | | - additionalTransactionResponseMetadata.Add("VoucherMessage", result.Data.Message); |
71 | | - additionalTransactionResponseMetadata.Add("VoucherExpiryDate", result.Data.ExpiryDate.ToString("yyyy-MM-dd")); |
72 | 67 |
|
73 | | - return Result.Success(new OperatorResponse |
74 | | - { |
75 | | - TransactionId = transactionId.ToString("N"), |
76 | | - ResponseCode = "0000", |
77 | | - ResponseMessage = "SUCCESS", |
78 | | - // This may contain the voucher details to be logged with the transaction, and for possible receipt email/print |
79 | | - AdditionalTransactionResponseMetadata = additionalTransactionResponseMetadata, |
80 | | - AuthorisationCode = "ABCD1234", |
81 | | - IsSuccessful = true |
82 | | - }); |
| 68 | + if (result.IsFailed) { |
| 69 | + Logger.LogWarning($"Error issuing voucher {result.Message}"); |
| 70 | + return ResultHelpers.CreateFailure(result); |
83 | 71 | } |
84 | 72 |
|
85 | | - // TODO: handle a failed issue case |
86 | | - return null; |
| 73 | + // Build the response metadata |
| 74 | + Dictionary<String, String> additionalTransactionResponseMetadata = new Dictionary<String, String>(); |
| 75 | + additionalTransactionResponseMetadata.Add("VoucherCode", result.Data.VoucherCode); |
| 76 | + additionalTransactionResponseMetadata.Add("VoucherMessage", result.Data.Message); |
| 77 | + additionalTransactionResponseMetadata.Add("VoucherExpiryDate", result.Data.ExpiryDate.ToString("yyyy-MM-dd")); |
| 78 | + |
| 79 | + return Result.Success(new OperatorResponse |
| 80 | + { |
| 81 | + TransactionId = transactionId.ToString("N"), |
| 82 | + ResponseCode = "0000", |
| 83 | + ResponseMessage = "SUCCESS", |
| 84 | + // This may contain the voucher details to be logged with the transaction, and for possible receipt email/print |
| 85 | + AdditionalTransactionResponseMetadata = additionalTransactionResponseMetadata, |
| 86 | + AuthorisationCode = "ABCD1234", |
| 87 | + IsSuccessful = true |
| 88 | + }); |
| 89 | + |
| 90 | + |
87 | 91 | } |
88 | 92 | } |
89 | 93 | } |
0 commit comments