📄 MatDenDagen/Infrastructure/Storage/StorageServiceExtensions.cs
using System;
using MatDenDagen.Infrastructure.Storage.BlobStorage;
using MatDenDagen.Infrastructure.Storage.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;

namespace MatDenDagen.Infrastructure.Storage;

public static class StorageServiceExtensions
{
    public static IServiceCollection AddStorageServices(this IServiceCollection services)
    {
        services.TryAddSingleton(TimeProvider.System);

        services.AddBlobStorageOptions().AddTransient<BlobStorageService>();

        services.AddDbContext<QuestionnaireContext>(
            (sp, options) => options.UseSqlite(sp.GetRequiredService<IConfiguration>().GetConnectionString("database"))
        );
        services.AddHostedService<StartupMigration>();

        return services;
    }
}