initial commit

This commit is contained in:
2026-07-21 14:22:06 +07:00
commit 2d7959f202
572 changed files with 45295 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
using Microsoft.EntityFrameworkCore;
namespace Indotalent.Infrastructure.Database;
public static class DI
{
public static IServiceCollection AddDatabaseService(this IServiceCollection services, IConfiguration configuration)
{
var dbSettings = configuration.GetSection("DatabaseSettings").Get<DatabaseSettingsModel>();
if (dbSettings?.MsSQL?.IsUsed == true)
{
services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(
dbSettings.MsSQL.ConnectionString,
sqlOptions => {
sqlOptions.CommandTimeout(dbSettings.MsSQL.TimeoutInSeconds);
}
)
);
}
else if (dbSettings?.PostgreSQL?.IsUsed == true)
{
services.AddDbContext<AppDbContext>(options =>
options.UseNpgsql(
dbSettings.PostgreSQL.ConnectionString,
npgsqlOptions => {
npgsqlOptions.CommandTimeout(dbSettings.PostgreSQL.TimeoutInSeconds);
}
)
);
}
else if (dbSettings?.MySQL?.IsUsed == true)
{
services.AddDbContext<AppDbContext>(options =>
options.UseMySQL(
dbSettings.MySQL.ConnectionString,
mySqlOptions => {
mySqlOptions.CommandTimeout(dbSettings.MySQL.TimeoutInSeconds);
mySqlOptions.MigrationsAssembly(typeof(AppDbContext).Assembly.FullName);
}
)
);
}
services.AddScoped<DatabaseService>();
return services;
}
}