using Microsoft.EntityFrameworkCore; using Models.Interfaces; namespace Models.Repositories { public class GenericRepository : IGenericRepository where T : class { private readonly DbContext _context; private readonly DbSet _dbSet; public GenericRepository(DbContext 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); } } }