import { Category } from "../models/category";
import { IDataService } from "../services/data/IDataService";
import { IRepository } from "./IRepository";

export class CategoryRepository implements IRepository<Category> {
    private dataService: IDataService<Category>;

    constructor(dataService: IDataService<Category>) {
        this.dataService = dataService;
    }

    async create(item: Category): Promise<Category> {
        return this.dataService.create(item);
    }

    async findById(id: number): Promise<Category | null> {
        return this.dataService.findById(id);
    }

    async findAll(): Promise<Category[]> {
        return this.dataService.findAll();
    }

    async update(id: number, item: Partial<Category>): Promise<Category | null> {
        return this.dataService.update(id, item);
    }

    async delete(id: number): Promise<boolean> {
        return this.dataService.delete(id);
    }
}