using AutoMapper; using HardwarePerformance.Models.DTOs; using HardwarePerformance.Repositories; namespace HardwarePerformance.Services { public class CategoryService : ICategoryService { private readonly ICategoryRepository _categoryRepository; private readonly IMapper _mapper; public CategoryService(ICategoryRepository categoryRepository, IMapper mapper) { _categoryRepository = categoryRepository; _mapper = mapper; } public async Task> GetAllCategoriesAsync() { var categories = await _categoryRepository.GetAllAsync(); return _mapper.Map>(categories); } public async Task GetCategoryByIdAsync(int id) { var category = await _categoryRepository.GetByIdAsync(id); return category != null ? _mapper.Map(category) : null; } } }