using ConstructorApp.DataAccessLayer.Abstract; using ConstructorApp.DataAccessLayer.Concrete; using Microsoft.EntityFrameworkCore; namespace ConstructorApp.DataAccessLayer.Repositories { public class GenericRepository : IGenericDal where T : class { private readonly ConstructorContext _context; public GenericRepository(ConstructorContext context) { _context = context; } public void Add(T entity) { _context.Add(entity); _context.SaveChanges(); } public void Delete(T entity) { _context.Remove(entity); _context.SaveChanges(); } public T GetByID(int id) { return _context.Set().Find(id); } public List GetListAll() { return _context.Set().ToList(); } public async Task> GetListAllAsync() { return await _context.Set().ToListAsync(); } public void Update(T entity) { _context.Update(entity); _context.SaveChanges(); } } }