from sqlalchemy.orm import Session from app.domain.models.lecture import Lecture class LecturesRepository: def __init__(self, db: Session): self.db = db def get_all(self): return self.db.query(Lecture).all() def get_by_id(self, lecture_id: int): return self.db.query(Lecture).filter(Lecture.id == lecture_id).first() def create(self, lecture: Lecture): self.db.add(lecture) self.db.commit() self.db.refresh(lecture) return lecture def update(self, lecture: Lecture): self.db.merge(lecture) self.db.commit() self.db.refresh(lecture) return lecture def delete(self, lecture_id: int): lecture = self.db.query(Lecture).filter(Lecture.id == lecture_id).first() if lecture: self.db.delete(lecture) self.db.commit() return lecture return None