Files
WorkTime/WorkTime.Database/ServiceCollectionExtensions.cs
2025-11-12 17:06:14 +01:00

16 lines
676 B
C#

using Microsoft.Extensions.DependencyInjection;
using WorkTime.Database.Repositories;
using WorkTime.Models.Repositories;
namespace WorkTime.Database;
public static class ServiceCollectionExtensions {
public static void AddDatabase(this IServiceCollection services, string basePath) {
services.AddSqlite<DatabaseContext>($"Filename={Path.Combine(basePath, "data.db")}");
services.AddHostedService<DbMigrationService>();
services.AddTransient<ITimeEntryRepository, TimeEntryRepository>();
services.AddTransient<ISettingsRepository, SettingsRepository>(_ => new SettingsRepository(Path.Combine(basePath, "settings.json")));
}
}