import { Task } from "../models/task";
import { IDataService } from "../services/data/IDataService";
import { IRepository } from "./IRepository";

export class TaskRepository implements IRepository<Task> {
    private dataService: IDataService<Task>;

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

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

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

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

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

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