Skip to content

Commit cf55774

Browse files
fix minor issues
1 parent 6bb4614 commit cf55774

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

TransactionProcessor.Mobile.BusinessLogic/RequestHandlers/LoginRequestHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public async Task<Result<TokenResponseModel>> Handle(LogonCommands.GetTokenComma
3535

3636
Configuration configuration = this.ApplicationCache.GetConfiguration();
3737
if (configuration == null) {
38-
return Result.Failure<TokenResponseModel>("App configuration is not available. Please restart the application and try again.");
38+
return Result.Failure("App configuration is not available. Please restart the application and try again.");
3939
}
4040

4141
Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode();
@@ -74,7 +74,7 @@ public async Task<Result<TokenResponseModel>> Handle(LogonCommands.RefreshTokenC
7474
{
7575
Configuration configuration = this.ApplicationCache.GetConfiguration();
7676
if (configuration == null) {
77-
return Result.Failure<TokenResponseModel>("App configuration is not available. Token refresh failed.");
77+
return Result.Failure("App configuration is not available. Token refresh failed.");
7878
}
7979

8080
Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode();

TransactionProcessor.Mobile.BusinessLogic/RequestHandlers/MerchantRequestHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using MediatR;
2+
using Microsoft.Extensions.Caching.Memory;
23
using Shared.Results;
34
using SimpleResults;
45
using TransactionProcessor.Mobile.BusinessLogic.Common;

TransactionProcessor.Mobile.BusinessLogic/Services/BalanceRefresher.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ public interface IBalanceRefresher
1515
public class BalanceRefresher : IBalanceRefresher
1616
{
1717
private readonly IApplicationCache ApplicationCache;
18-
private readonly IMerchantService MerchantService;
18+
private readonly Func<Boolean, IMerchantService> MerchantServiceResolver;
1919
private CancellationTokenSource? _cts;
2020

2121
public event Action<Decimal> BalanceChanged;
2222

23-
public BalanceRefresher(IApplicationCache applicationCache, IMerchantService merchantService) {
23+
public BalanceRefresher(IApplicationCache applicationCache, Func<Boolean, IMerchantService> merchantServiceResolver) {
2424
this.ApplicationCache = applicationCache;
25-
this.MerchantService = merchantService;
25+
this.MerchantServiceResolver = merchantServiceResolver;
2626
}
2727

2828
public void StartRefreshing()
@@ -65,9 +65,12 @@ private async Task RefreshBalanceAsync()
6565

6666
private async Task<decimal> GetBalanceFromApi()
6767
{
68-
var result = await this.MerchantService.GetMerchantBalance(CancellationToken.None);
69-
if (result.IsSuccess)
70-
{
68+
Boolean useTrainingMode = this.ApplicationCache.GetUseTrainingMode();
69+
IMerchantService merchantService = this.MerchantServiceResolver(useTrainingMode);
70+
71+
var result = await merchantService.GetMerchantBalance(CancellationToken.None);
72+
if (result.IsSuccess) {
73+
Logger.LogInformation($"Refreshed merchant balance: {result.Data}");
7174
return result.Data;
7275
}
7376

0 commit comments

Comments
 (0)