Skip to content

Commit 73b4506

Browse files
Clean up unused code and standardize navigation
Removed commented-out and legacy code across services, view models, and pages to improve clarity. Updated navigation methods to use this.NavigateTo for consistency. Cleaned up using directives and unified namespace declarations in DialogService and ShellNavigationService. Minor formatting and logging improvements applied throughout.
1 parent 28237d4 commit 73b4506

13 files changed

Lines changed: 37 additions & 218 deletions

File tree

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,5 @@
11
namespace TransactionProcessor.Mobile.BusinessLogic.Common
22
{
3-
/*public class IdGenerationService
4-
{
5-
internal delegate Guid GenerateUniqueIdFromObject(Object payload);
6-
7-
internal delegate Guid GenerateUniqueIdFromString(String payload);
8-
9-
10-
private static readonly JsonSerialiser JsonSerialiser = new(() => new JsonSerializerSettings
11-
{
12-
Formatting = Formatting.None
13-
});
14-
15-
private static readonly GenerateUniqueIdFromObject GenerateUniqueId =
16-
data => IdGenerationService.GenerateGuidFromString(IdGenerationService.JsonSerialiser.Serialise(data));
17-
18-
private static readonly GenerateUniqueIdFromString GenerateGuidFromString = uniqueKey => {
19-
using SHA256 sha256Hash = SHA256.Create();
20-
//Generate hash from the key
21-
Byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(uniqueKey));
22-
23-
Byte[] j = bytes.Skip(Math.Max(0, bytes.Count() - 16)).ToArray(); //Take last 16
24-
25-
//Create our Guid.
26-
return new Guid(j);
27-
};
28-
29-
public static Guid GenerateGuid(Object o) => IdGenerationService.GenerateUniqueId(o);
30-
}*/
31-
323
public static class CorrelationIdProvider
334
{
345
private static readonly AsyncLocal<string?> _correlationId = new();
@@ -47,13 +18,6 @@ public static string CorrelationId
4718
set => _correlationId.Value = value;
4819
}
4920

50-
//public static string? CorrelationId
51-
//{
52-
// get => _correlationId.Value;
53-
// set => _correlationId.Value = value;
54-
//}
55-
56-
//public static void New() => CorrelationId = Guid.NewGuid().ToString();
5721
public static void NewId() => CorrelationId = Guid.NewGuid().ToString();
5822
}
5923
}
Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
using System.Diagnostics.CodeAnalysis;
22

33
namespace TransactionProcessor.Mobile.BusinessLogic.Models;
4-
//using Microsoft.Maui.Graphics;
54

65
[ExcludeFromCodeCoverage]
76
public class LogMessageModel
87
{
9-
#region Properties
10-
118
public DateTime EntryDateTime { get; set; }
129

1310
public Int32 Id { get; set; }
@@ -17,20 +14,4 @@ public class LogMessageModel
1714
public String LogLevelString { get; set; }
1815

1916
public String Message { get; set; }
20-
21-
//public Color TextColor {
22-
// get {
23-
// return this.LogLevel switch {
24-
// LogLevel.Debug => Colors.Gray,
25-
// LogLevel.Trace => Colors.Gray,
26-
// LogLevel.Info => Colors.Blue,
27-
// LogLevel.Warn => Colors.Orange,
28-
// LogLevel.Error => Colors.Red,
29-
// LogLevel.Fatal => Colors.Red,
30-
// _ => Colors.Gray
31-
// };
32-
// }
33-
//}
34-
35-
#endregion
3617
}

TransactionProcessor.Mobile.BusinessLogic/Services/ConfigurationService.cs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,7 @@ private String BuildRequestUrl(String route)
3535

3636
return requestUri;
3737
}
38-
39-
//protected override async Task<String> HandleResponse(HttpResponseMessage responseMessage,
40-
// CancellationToken cancellationToken)
41-
//{
42-
// String content = await responseMessage.Content.ReadAsStringAsync();
43-
44-
// if (responseMessage.StatusCode == HttpStatusCode.NotFound)
45-
// {
46-
// // No error as maybe running under CI (which has no internet)
47-
// return content;
48-
// }
49-
50-
// return await base.HandleResponse(responseMessage, cancellationToken);
51-
//}
52-
38+
5339
public async Task<Result<Configuration>> GetConfiguration(String deviceIdentifier,
5440
CancellationToken cancellationToken)
5541
{
@@ -66,17 +52,6 @@ public async Task<Result<Configuration>> GetConfiguration(String deviceIdentifie
6652
if (apiResponse.IsFailed)
6753
return ResultHelpers.CreateFailure(apiResponse);
6854

69-
//response = new Configuration
70-
//{
71-
// ApplicationUpdateUri = "",
72-
// ClientId = "mobileAppClient",
73-
// ClientSecret = "d192cbc46d834d0da90e8a9d50ded543",
74-
// EnableAutoUpdates = false,
75-
// LogLevel = LogLevel.Debug,
76-
// SecurityServiceUri = "https://192.168.1.86:5001",
77-
// TransactionProcessorAclUri = "http://192.168.1.86:5003",
78-
//};
79-
//return response;
8055
Logger.LogDebug($"Configuration Response is {StringSerialiser.Serialise(apiResponse.Data)}");
8156
Logger.LogDebug($"About to build Configuration");
8257
response = new Configuration() {

TransactionProcessor.Mobile.BusinessLogic/Services/MerchantService.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,7 @@ public async Task<Result<Decimal>> GetMerchantBalance(CancellationToken cancella
110110
Logger.LogInformation("About to request merchant balance");
111111
Logger.LogDebug($"Merchant Balance Request details: Access Token {accessToken.AccessToken}");
112112

113-
//MerchantBalanceResponse merchantBalance = new MerchantBalanceResponse {
114-
// AvailableBalance = 0,
115-
// Balance = 0
116-
// };
117-
//await this.EstateClient.GetMerchantBalance(accessToken.AccessToken, estateId, merchantId, cancellationToken);
118-
119113
Logger.LogInformation("Balance for merchant requested successfully");
120-
//Logger.LogDebug($"Merchant Balance Response: [{JsonConvert.SerializeObject(merchantBalance)}]");
121-
122114
return Result.Success(0.0m);
123115
}
124116
catch(Exception ex) {
@@ -135,24 +127,6 @@ public async Task<Result<MerchantDetailsModel>> GetMerchantDetails(CancellationT
135127
Logger.LogInformation("About to request merchant details");
136128
Logger.LogDebug($"Merchant Details Request details: Access Token {accessToken.AccessToken}");
137129

138-
//HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
139-
//request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.AccessToken);
140-
//var httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);
141-
142-
//// Process the response
143-
//Result<String> content = await this.HandleResponseX(httpResponse, cancellationToken);
144-
145-
//if (content.IsFailed)
146-
//{
147-
// Logger.LogInformation($"GetMerchantContracts failed {content.Status}");
148-
// return Result.Failure(content.Message);
149-
//}
150-
151-
//Logger.LogDebug($"Transaction Response details: Status {httpResponse.StatusCode} Payload {content.Data}");
152-
153-
////ResponseData<MerchantResponse> responseData = this.HandleResponseContent<MerchantResponse>(content.Data);
154-
//MerchantResponse responseData = JsonConvert.DeserializeObject<MerchantResponse>(content.Data);
155-
156130
Result<MerchantResponse>? responseDataResult = await this.Get<MerchantResponse>(requestUri, accessToken.AccessToken, cancellationToken);
157131

158132
if (responseDataResult.IsFailed)
@@ -171,8 +145,6 @@ public async Task<Result<MerchantDetailsModel>> GetMerchantDetails(CancellationT
171145
NextStatementDate = responseDataResult.Data.NextStatementDate,
172146
LastStatementDate = new DateTime(),
173147
SettlementSchedule = responseDataResult.Data.SettlementSchedule.ToString(),
174-
//AvailableBalance = merchantResponse.AvailableBalance,
175-
//Balance = merchantResponse.Balance,
176148
Contact = new ContactModel {
177149
Name = responseDataResult.Data.Contacts.First().ContactName,
178150
EmailAddress = responseDataResult.Data.Contacts.First().ContactEmailAddress,

TransactionProcessor.Mobile.BusinessLogic/UIServices/IDialogService.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@ Task ShowInformationToast(String message,
2626
TimeSpan? duration = null,
2727
CancellationToken cancellationToken = default);
2828

29-
//Task<String> ShowPrompt(String title,
30-
// String message,
31-
// String acceptString,
32-
// String cancelString,
33-
// String placeHolder = "",
34-
// Int32 maxLength = -1,
35-
// Keyboard keyboard = null,
36-
// String initialValue = "");
37-
3829
Task ShowWarningToast(String message,
3930
Action? action = null,
4031
String? actionButtonText = "OK",

TransactionProcessor.Mobile.BusinessLogic/ViewModels/LoginPageViewModel.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,8 @@ private async Task Logon(){
246246
Result<List<ContractProductModel>> getMerchantContractProductsResult = await this.GetMerchantContractProducts();
247247
this.HandleResult(getMerchantContractProductsResult);
248248

249-
//await this.WriteTimingTrace(sw, "After GetMerchantContractProducts");
250-
//Result<Decimal> getMerchantBalanceResult = await this.GetMerchantBalance();
251-
//this.HandleResult(getMerchantBalanceResult);
252-
253-
//await this.WriteTimingTrace(sw, "After GetMerchantBalance");
249+
await this.WriteTimingTrace(sw, "After GetMerchantContractProducts");
250+
254251
this.ApplicationCache.SetIsLoggedIn(true);
255252

256253
this.BalanceRefresher.StartRefreshing();

TransactionProcessor.Mobile/App.xaml.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ public App(IApplicationThemeService applicationThemeService)
153153
#endif
154154
MainPage = new AppShell();
155155

156-
//RegisterRouteOnce("login", typeof(LoginPage));
157-
//RegisterRouteOnce("home", typeof(HomePage));
158156

159157
RegisterRouteOnce(nameof(MobileTopupSelectOperatorPage), typeof(MobileTopupSelectOperatorPage));
160158
RegisterRouteOnce(nameof(MobileTopupSelectProductPage), typeof(MobileTopupSelectProductPage));

TransactionProcessor.Mobile/AppShell.xaml.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ public AppShell()
1313
protected override async void OnNavigating(ShellNavigatingEventArgs args)
1414
{
1515
base.OnNavigating(args);
16-
17-
//Logger.LogDebug($"In OnNavigating - Source [{args.Source.ToString()}] {JsonConvert.SerializeObject(args)}");
1816
if (args.Source == ShellNavigationSource.ShellSectionChanged)
1917
{
2018
List<Page> existingPages = Navigation.NavigationStack.ToList();

TransactionProcessor.Mobile/Extensions/MauiAppBuilderExtensions.cs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Net.Security;
22
using banditoth.MAUI.DeviceId;
33
using SecurityService.Client;
4-
using TransactionMobile.Maui.UIServices;
54
using TransactionProcessor.Mobile.BusinessLogic.Database;
65
using TransactionProcessor.Mobile.BusinessLogic.RequestHandlers;
76
using TransactionProcessor.Mobile.BusinessLogic.Services;
@@ -186,32 +185,8 @@ public static MauiAppBuilder ConfigureUIServices(this MauiAppBuilder builder) {
186185
}
187186

188187
public static MauiAppBuilder ConfigureRequestHandlers(this MauiAppBuilder builder) {
189-
//builder.Services.AddSingleton<MediatRServiceConfiguration>();
190-
//builder.Services.AddSingleton<ISender, Mediator>();
191-
//builder.Services.AddSingleton<IPublisher, Mediator>();
192-
//builder.Services.AddSingleton<IMediator, Mediator>();
193188
builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(LoginRequestHandler).Assembly));
194-
//builder.Services.AddSingleton<IRequestHandler<GetConfigurationRequest, Result<Configuration>>, LoginRequestHandler>();
195-
//builder.Services.AddSingleton<IRequestHandler<LoginRequest, Result<TokenResponseModel>>, LoginRequestHandler>();
196-
//builder.Services.AddSingleton<IRequestHandler<RefreshTokenRequest, Result<TokenResponseModel>>, LoginRequestHandler>();
197-
198-
//builder.Services.AddSingleton<IRequestHandler<GetContractProductsRequest, Result<List<ContractProductModel>>>, MerchantRequestHandler>();
199-
//builder.Services.AddSingleton<IRequestHandler<GetProductOperators, Result<List<ContractOperatorModel>>>, MerchantRequestHandler>();
200-
//builder.Services.AddSingleton<IRequestHandler<GetMerchantBalanceRequest, Result<Decimal>>, MerchantRequestHandler>();
201-
//builder.Services.AddSingleton<IRequestHandler<GetMerchantDetailsRequest, Result<MerchantDetailsModel>>, MerchantRequestHandler>();
202-
203-
//builder.Services.AddSingleton<IRequestHandler<PerformMobileTopupRequest, Result<PerformMobileTopupResponseModel>>, TransactionRequestHandler>();
204-
//builder.Services.AddSingleton<IRequestHandler<LogonTransactionRequest, Result<PerformLogonResponseModel>>, TransactionRequestHandler>();
205-
//builder.Services.AddSingleton<IRequestHandler<PerformVoucherIssueRequest, Result<PerformVoucherIssueResponseModel>>, TransactionRequestHandler>();
206-
//builder.Services.AddSingleton<IRequestHandler<PerformReconciliationRequest, Result<PerformReconciliationResponseModel>>, TransactionRequestHandler>();
207-
//builder.Services.AddSingleton<IRequestHandler<PerformBillPaymentGetAccountRequest, Result<PerformBillPaymentGetAccountResponseModel>>, TransactionRequestHandler>();
208-
//builder.Services.AddSingleton<IRequestHandler<PerformBillPaymentGetMeterRequest, Result<PerformBillPaymentGetMeterResponseModel>>, TransactionRequestHandler>();
209-
//builder.Services.AddSingleton<IRequestHandler<PerformBillPaymentMakePostPaymentRequest, Result<PerformBillPaymentMakePaymentResponseModel>>, TransactionRequestHandler>();
210-
//builder.Services.AddSingleton<IRequestHandler<PerformBillPaymentMakePrePaymentRequest, Result<PerformBillPaymentMakePaymentResponseModel>>, TransactionRequestHandler>();
211-
212-
//builder.Services.AddSingleton<IRequestHandler<UploadLogsRequest, Boolean>, SupportRequestHandler>();
213-
//builder.Services.AddSingleton<IRequestHandler<ViewLogsRequest, List<LogMessage>>, SupportRequestHandler>();
214-
189+
215190
return builder;
216191
}
217192

TransactionProcessor.Mobile/MauiProgram.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static MauiApp CreateMauiApp()
3131
}).Services.AddTransient<IDeviceService, DeviceService>()
3232
.AddMemoryCache();
3333

34-
builder.Logging.SetMinimumLevel(LogLevel.Trace);//.AddConsole();
34+
builder.Logging.SetMinimumLevel(LogLevel.Trace);;
3535

3636
Container = builder.Build();
3737

0 commit comments

Comments
 (0)