using Microsoft.EntityFrameworkCore; using Models.Interfaces; using Models.Models; namespace Models.Repositories { public class GenericRepository : IGenericRepository where T : class { private readonly PhronCareOperationsHubContext _context; private readonly DbSet _dbSet; public GenericRepository(PhronCareOperationsHubContext context) { _context = context; _dbSet = _context.Set(); } public async Task GetByIdAsync(int id) { return await _dbSet.FindAsync(id); } public async Task> GetAllAsync() { return await _dbSet.ToListAsync(); } public async Task AddAsync(T entity) { await _dbSet.AddAsync(entity); } public void Update(T entity) { _dbSet.Update(entity); } public void Delete(T entity) { _dbSet.Remove(entity); } } }