using Microsoft.Extensions.Options;
using MongoDB.Driver;

namespace Guestlist;

public sealed class MongoOptions
{
    public string ConnectionString { get; set; } = "";
    public string DatabaseName { get; set; } = "";
}

public sealed class MongoDbContext
{
    public IMongoClient Client { get; }
    public IMongoDatabase Database { get; }
    public string DatabaseName { get; }

    public MongoDbContext(IOptions<MongoOptions> options)
    {
        Client = new MongoClient(options.Value.ConnectionString);
        DatabaseName = options.Value.DatabaseName;
        Database = Client.GetDatabase(DatabaseName);
    }
}
