using CvMatcher.Data;
using CvMatcher.Data.Repositories.Contracts;
using Microsoft.EntityFrameworkCore;

namespace CvMatcher.Data.Repositories;

public sealed class EfAiPromptsRepository : IAiPromptsRepository
{
    private readonly CvMatcherDbContext _db;

    public EfAiPromptsRepository(CvMatcherDbContext db)
    {
        _db = db;
    }

    public async Task<string?> GetAsync(string key, string language, CancellationToken ct)
    {
        return await _db.AiPrompts
            .AsNoTracking()
            .Where(x => x.Key == key && x.Language == language)
            .Select(x => x.Value)
            .FirstOrDefaultAsync(ct);
    }
}
