Skip to content

Commit a3c41fb

Browse files
committed
feat: local data persistence setup
Refs: #41
1 parent 5612597 commit a3c41fb

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/frontend/src/FinTrack.Maui/App.xaml.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,32 @@ private async Task InitializeDatabaseAsync()
4141
System.Diagnostics.Debug.WriteLine($"Database initialization failed: {ex.Message}");
4242
}
4343
}
44+
45+
protected override async void OnStart()
46+
{
47+
base.OnStart();
48+
49+
// Initialize database on app start
50+
await InitializeDatabaseAsync();
51+
}
52+
53+
private async Task InitializeDatabaseAsync()
54+
{
55+
try
56+
{
57+
// Get the service provider from the current application
58+
var serviceProvider = IPlatformApplication.Current?.Services;
59+
if (serviceProvider != null)
60+
{
61+
using var scope = serviceProvider.CreateScope();
62+
var databaseService = scope.ServiceProvider.GetRequiredService<DatabaseService>();
63+
await databaseService.InitializeDatabaseAsync();
64+
}
65+
}
66+
catch (Exception ex)
67+
{
68+
// Log error but don't crash the app
69+
System.Diagnostics.Debug.WriteLine($"Database initialization failed: {ex.Message}");
70+
}
71+
}
4472
}

src/frontend/src/FinTrack.Maui/MauiProgram.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public static MauiApp CreateMauiApp()
7373

7474

7575

76+
77+
7678
return builder.Build();
7779
}
7880
}

0 commit comments

Comments
 (0)