This commit is contained in:
andrei-mihnea-cerbu
2024-04-08 00:03:24 +03:00
parent 2ccec617a5
commit b48d5ee19e
168 changed files with 2877 additions and 1146 deletions
@@ -12,7 +12,7 @@ public class BasePostgreSQLRepository<T> where T : class
_context = context;
}
public async Task<T> GetByIdAsync(Guid id)
public async Task<T?> GetByIdAsync(Guid id)
{
return await _context.Set<T>().FindAsync(id);
}
@@ -40,4 +40,4 @@ public class BasePostgreSQLRepository<T> where T : class
_context.Set<T>().Remove(entity);
await _context.SaveChangesAsync();
}
}
}
@@ -5,8 +5,16 @@ using Microsoft.EntityFrameworkCore;
namespace Infrastructure.Services.PostgreSQL;
public class DoctorRepository(HealthcareManagerDatabase context) : BasePostgreSQLRepository<Doctor>(context), IDoctorRepository
public class DoctorRepository(HealthcareManagerDatabase context)
: BasePostgreSQLRepository<Doctor>(context), IDoctorRepository
{
public async Task<Doctor?> FindByEmailAsync(string email)
=> await _context.Doctors.FirstOrDefaultAsync(d => d.Email == email);
}
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);
}
}
@@ -12,6 +12,7 @@ public class MedicalHistoryRepository : BasePostgreSQLRepository<MedicalHistory>
}
public async Task<MedicalHistory?> GetByUserIdAsync(Guid userId)
=> await _context.MedicalHistories.FirstOrDefaultAsync(d => d.UserId == userId);
}
{
return await _context.MedicalHistories.FirstOrDefaultAsync(d => d.UserId == userId);
}
}
@@ -1,12 +0,0 @@
using Application.Services.Database;
using Core.Entities;
using Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
namespace Infrastructure.Services.PostgreSQL;
public class PacientRepository(HealthcareManagerDatabase context) : BasePostgreSQLRepository<Pacient>(context), IPacientRepository
{
public async Task<Pacient?> FindByEmailAsync(string email)
=> await _context.Pacients.FirstOrDefaultAsync(d => d.Email == email);
}
@@ -0,0 +1,15 @@
using Application.Services.Database;
using Core.Entities;
using Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
namespace Infrastructure.Services.PostgreSQL;
public class PatientRepository(HealthcareManagerDatabase context)
: BasePostgreSQLRepository<Patient>(context), IPatientRepository
{
public async Task<Patient?> FindByEmailAsync(string email)
{
return await _context.Pacients.FirstOrDefaultAsync(d => d.Email == email);
}
}