from sqlalchemy.orm import Session
from app.model.task_model import Task

class TaskDAO:
    def __init__(self, db_session: Session):
        self.db_session = db_session

    def get_all(self):
        return self.db_session.query(Task).all()

    def get_by_id(self, task_id: int):
        return self.db_session.query(Task).get(task_id)

    def create(self, task: Task):
        self.db_session.add(task)
        self.db_session.commit()
        return task

    def update(self, task: Task):
        self.db_session.commit()
        return task

    def delete(self, task: Task):
        self.db_session.delete(task)
        self.db_session.commit()
