diff --git a/API/ROLAC.API/Data/DbSeeder.cs b/API/ROLAC.API/Data/DbSeeder.cs index a5aa05d..14aca54 100644 --- a/API/ROLAC.API/Data/DbSeeder.cs +++ b/API/ROLAC.API/Data/DbSeeder.cs @@ -5,6 +5,15 @@ namespace ROLAC.API.Data; public static class DbSeeder { + private static readonly (string En, string Zh, int Sort)[] GivingCategorySeed = + [ + ("Tithe", "什一奉獻", 1), + ("General Offering", "一般奉獻", 2), + ("Special Offering", "特別奉獻", 3), + ("Building Fund", "建堂基金", 4), + ("Mission", "宣教奉獻", 5), + ]; + private static readonly (string Name, string Description)[] Roles = [ ("super_admin", "System administrator — full access"), @@ -37,6 +46,25 @@ public static class DbSeeder } } + public static async Task SeedGivingCategoriesAsync(AppDbContext db) + { + foreach (var (en, zh, sort) in GivingCategorySeed) + { + if (!db.GivingCategories.Any(c => c.Name_en == en)) + { + db.GivingCategories.Add(new GivingCategory + { + Name_en = en, + Name_zh = zh, + SortOrder = sort, + IsActive = true, + // Audit fields are stamped by AuditSaveChangesInterceptor on save. + }); + } + } + await db.SaveChangesAsync(); + } + /// /// Seeds roles and (in Development) the default admin account. /// Called once on application startup after migrations have been applied. @@ -49,6 +77,9 @@ public static class DbSeeder await SeedRolesAsync(roleManager); + var db = services.GetRequiredService(); + await SeedGivingCategoriesAsync(db); + if (env.IsDevelopment()) await SeedAdminUserAsync(userManager); }