📄 ScreeningRepository.cs
using Microsoft.Data.Sqlite;
using Microsoft.Extensions.Configuration;

internal sealed class ScreeningRepository
{
    private readonly string _connectionString;

    public ScreeningRepository(IConfiguration configuration)
    {
        _connectionString = configuration.GetConnectionString("Screenings") ?? "DataSource=screenings.db";
        Initialize();
    }

    private void Initialize()
    {
        using var connection = new SqliteConnection(_connectionString);
        connection.Open();
        using var command = connection.CreateCommand();
        command.CommandText =
            "CREATE TABLE IF NOT EXISTS NotifiedScreenings (Id TEXT PRIMARY KEY, NotifiedAt TEXT NOT NULL)";
        command.ExecuteNonQuery();
    }

    public async Task<bool> HasBeenNotifiedAsync(string screeningId)
    {
        await using var connection = new SqliteConnection(_connectionString);
        await connection.OpenAsync();
        using var command = connection.CreateCommand();
        command.CommandText = "SELECT 1 FROM NotifiedScreenings WHERE Id = $id";
        command.Parameters.AddWithValue("$id", screeningId);
        return await command.ExecuteScalarAsync() is not null;
    }

    public async Task MarkNotifiedAsync(string screeningId)
    {
        await using var connection = new SqliteConnection(_connectionString);
        await connection.OpenAsync();
        using var command = connection.CreateCommand();
        command.CommandText = "INSERT OR IGNORE INTO NotifiedScreenings (Id, NotifiedAt) VALUES ($id, $at)";
        command.Parameters.AddWithValue("$id", screeningId);
        command.Parameters.AddWithValue("$at", DateTimeOffset.UtcNow.ToString("O"));
        await command.ExecuteNonQueryAsync();
    }
}