using Microsoft.EntityFrameworkCore; namespace Infrastructure.Services.PostgreSQL; public class BasePostgreSqlRepository(HealthcareManagerDatabase context) where T : class { protected readonly HealthcareManagerDatabase Context = context; public async Task GetByIdAsync(Guid id, CancellationToken token) { return await Context.Set().FindAsync(id, token); } public async Task> GetAllAsync(CancellationToken token) { return await Context.Set().ToListAsync(token); } public async Task AddAsync(T entity, CancellationToken token) { await Context.Set().AddAsync(entity, token); await Context.SaveChangesAsync(token); } public async Task UpdateAsync(T entity, CancellationToken token) { Context.Set().Attach(entity); Context.Entry(entity).State = EntityState.Modified; await Context.SaveChangesAsync(token); } public async Task DeleteAsync(T entity, CancellationToken token) { Context.Set().Remove(entity); await Context.SaveChangesAsync(token); } }