using Microsoft.EntityFrameworkCore; using OilShopManagement.Data; using OilShopManagement.Models; namespace OilShopManagement.Repositories; public class ProductRepository : Repository, IProductRepository { public ProductRepository(ApplicationDbContext context) : base(context) { } public async Task> GetAllWithCategoryAsync() => await _dbSet.Include(p => p.Category).Where(p => p.IsActive).OrderBy(p => p.Name).ToListAsync(); public async Task GetWithCategoryAsync(int id) => await _dbSet.Include(p => p.Category).FirstOrDefaultAsync(p => p.Id == id); public async Task> GetLowStockProductsAsync() => await _dbSet.Include(p => p.Category) .Where(p => p.IsActive && p.CurrentStock <= p.MinStockLevel) .ToListAsync(); public async Task> SearchAsync(string searchTerm) => await _dbSet.Include(p => p.Category) .Where(p => p.IsActive && (p.Name.Contains(searchTerm) || (p.SKU != null && p.SKU.Contains(searchTerm)))) .ToListAsync(); public async Task> GetByCategoryAsync(int categoryId) => await _dbSet.Include(p => p.Category) .Where(p => p.IsActive && p.CategoryId == categoryId) .ToListAsync(); }