using Application.Services.Database;
using Core.Entities;
using Infrastructure.Data;
using Microsoft.EntityFrameworkCore;

namespace Infrastructure.Services.PostgreSQL;

public class DoctorRepository(HealthcareManagerDatabase context)
    : BasePostgreSQLRepository<Doctor>(context), IDoctorRepository
{
    public async Task<Doctor?> FindByEmailAsync(string email)
    {
        return await _context.Doctors.FirstOrDefaultAsync(d => d.Email == email);
    }

    public async Task<bool> CredentialsMatch(string email, string password)
    {
        return _context.Doctors.Any(u => u.Email == email && u.Password == password);
    }
}