using e_suite.API.Common.repository;
using e_suite.Database.Core;
using e_suite.Database.Core.Tables.Mail;
using eSuite.Core.MailService;
using Microsoft.EntityFrameworkCore;

namespace e_suite.Service.Mail.repository;

public class MailServiceRepository : RepositoryBase, IMailServiceRepository
{
    public MailServiceRepository(IEsuiteDatabaseDbContext databaseDbContext) : base(databaseDbContext)
    {
    }

    public async Task<MailTemplate?> GetMailTemplate(long domainId, MailType emailRequestEmailType, CancellationToken cancellationToken)
    {
        return await DatabaseDbContext.MailTemplates.SingleOrDefaultAsync(x =>
            !x.Deleted && x.DomainId == domainId && x.MailType == emailRequestEmailType, cancellationToken);
    }
}