Structurare backend

This commit is contained in:
andrei-mihnea-cerbu
2024-04-04 15:11:30 +03:00
parent 4d0636f011
commit d43beb66b6
87 changed files with 6272 additions and 0 deletions
@@ -0,0 +1,44 @@
using Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
namespace Infrastructure.Repositories
{
public class BaseRepository<T> where T : class
{
protected readonly HealthcareManagerContext _context;
public BaseRepository(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.Interfaces;
using Core.Entities;
using Infrastructure.Data;
namespace Infrastructure.Repositories
{
public class DoctorRepository : BaseRepository<Doctor>, IDoctorRepository
{
public DoctorRepository(HealthcareManagerContext context) : base(context)
{
}
}
}
@@ -0,0 +1,14 @@
using Application.Contracts.Interfaces;
using Core.Entities;
using Infrastructure.Data;
namespace Infrastructure.Repositories
{
public class MedicalHistoryRepository : BaseRepository<MedicalHistory>, IMedicalHistoryRepository
{
public MedicalHistoryRepository(HealthcareManagerContext context) : base(context)
{
}
}
}
@@ -0,0 +1,14 @@
using Application.Contracts.Interfaces;
using Core.Entities;
using Infrastructure.Data;
namespace Infrastructure.Repositories
{
public class PacientRepository : BaseRepository<Pacient>, IPacientRepository
{
public PacientRepository(HealthcareManagerContext context) : base(context)
{
}
}
}