MongoDB + PostgreSQL Injection

This commit is contained in:
andrei-mihnea-cerbu
2024-04-04 17:49:10 +03:00
parent 041abb5900
commit 22f171b560
143 changed files with 3239 additions and 437 deletions
@@ -0,0 +1,44 @@
using Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
namespace Infrastructure.Services.PostgreSQL
{
public class BasePostgreSQLRepository<T> where T : class
{
protected readonly HealthcareManagerContext _context;
public BasePostgreSQLRepository(HealthcareManagerContext context)
{
_context = context;
}
public async Task<T> GetByIdAsync(Guid id)
{
return await _context.Set<T>().FindAsync(id);
}
public async Task<List<T>> ListAllAsync()
{
return await _context.Set<T>().ToListAsync();
}
public async Task AddAsync(T entity)
{
await _context.Set<T>().AddAsync(entity);
await _context.SaveChangesAsync();
}
public async Task Update(T entity)
{
_context.Set<T>().Attach(entity);
_context.Entry(entity).State = EntityState.Modified;
await _context.SaveChangesAsync();
}
public async Task Delete(T entity)
{
_context.Set<T>().Remove(entity);
await _context.SaveChangesAsync();
}
}
}
@@ -0,0 +1,14 @@
using Application.Contracts.Database;
using Core.Entities;
using Infrastructure.Data;
namespace Infrastructure.Services.PostgreSQL
{
public class DoctorRepository : BasePostgreSQLRepository<Doctor>, IDoctorRepository
{
public DoctorRepository(HealthcareManagerContext context) : base(context)
{
}
}
}
@@ -0,0 +1,14 @@
using Application.Contracts.Database;
using Core.Entities;
using Infrastructure.Data;
namespace Infrastructure.Services.PostgreSQL
{
public class MedicalHistoryRepository : BasePostgreSQLRepository<MedicalHistory>, IMedicalHistoryRepository
{
public MedicalHistoryRepository(HealthcareManagerContext context) : base(context)
{
}
}
}
@@ -0,0 +1,14 @@
using Application.Contracts.Database;
using Core.Entities;
using Infrastructure.Data;
namespace Infrastructure.Services.PostgreSQL
{
public class PacientRepository : BasePostgreSQLRepository<Pacient>, IPacientRepository
{
public PacientRepository(HealthcareManagerContext context) : base(context)
{
}
}
}