def get_free_tables(self, seats: int, since: datetime, until: datetime): return (DBEngine.get_session().query(Table).join( Schedule, Schedule.StulID == Table.StulID).filter( Table.Pocetmist >= seats, cast(Schedule.Datumod, DateTime) <= since, cast(Schedule.Datumdo, DateTime) >= until, Schedule.Jedostupny == True).all())
def get(self, obj_id: int): return DBEngine.get_session().query(Table).filter( Table.StulID == obj_id).first()
def delete(self, obj: Address): if not self.get(obj.AdresaID): return False DBEngine.get_session().delete(obj) DBEngine.get_session().commit() return True
def get(self, obj_id: int): return DBEngine.get_session().query(Address).filter( Address.AdresaID == obj_id).first()
def delete(self, obj: Reservation): if not self.get(obj.RezervaceID): return False DBEngine.get_session().delete(obj) DBEngine.get_session().commit() return True
def get(self, obj_id: int): return DBEngine.get_session().query(Reservation).filter( Reservation.RezervaceID == obj_id).first()
def delete(self, obj: Alergen): if not self.get(obj.Cislo): return False DBEngine.get_session().delete(obj) DBEngine.get_session().commit() return True
def get(self, obj_id: int): return DBEngine.get_session().query(Alergen).filter( Alergen.Cislo == obj_id).first()
def get_all(self): schedules = DBEngine.get_session().query(Schedule).all() return schedules
def delete(self, obj: Schedule): if not self.get(obj.RozvrhID): return False DBEngine.get_session().delete(obj) DBEngine.get_session().commit() return True
def add(self, obj: Schedule): if self.get(obj.RozvrhID): return False DBEngine.get_session().add(obj) DBEngine.get_session().commit() return True
def get(self, obj_id: int): return DBEngine.get_session().query(Schedule).filter( Schedule.RozvrhID == obj_id).first()
def delete(self, obj: Table): if not self.get(obj.StulID): return False DBEngine.get_session().delete(obj) DBEngine.get_session().commit() return True
def add(self, obj: Table): if self.get(obj.StulID): return False DBEngine.get_session().add(obj) DBEngine.get_session().commit() return True
def delete(self, obj: Meal): if not self.get(obj.JidloID): return False DBEngine.get_session().delete(obj) DBEngine.get_session().commit() return True
def get(self, obj_id: int): return DBEngine.get_session().query(Customer).filter( Customer.UzivatelID == obj_id).first()
def get_all(self): meals = DBEngine.get_session().query(Meal).all() return meals
def add(self, obj: Customer): if self.get(obj.UzivatelID): return False DBEngine.get_session().add(obj) DBEngine.get_session().commit() return True
def add(self, obj: Alergen): if self.get(obj.Cislo): return False DBEngine.get_session().add(obj) DBEngine.get_session().commit() return True
def delete(self, obj: Customer): if not self.get(obj.UzivatelID): return False DBEngine.get_session().delete(obj) DBEngine.get_session().commit() return True
def get_all(self): alergens = DBEngine.get_session().query(Alergen).all() return alergens
def get_all(self): customers = DBEngine.get_session().query(Customer).all() return customers
def add(self, obj: Reservation): if self.get(obj.RezervaceID): return False DBEngine.get_session().add(obj) DBEngine.get_session().commit() return True
def get(self, obj_id: int): return DBEngine.get_session().query(Menu).filter( Menu.MenuID == obj_id).first()
def get_all(self): reservations = DBEngine.get_session().query(Reservation).all() return reservations
def get(self, obj_id: int): return DBEngine.get_session().query(Meal).filter( Meal.JidloID == obj_id).first()
def add(self, obj: Address): if self.get(obj.AdresaID): return False DBEngine.get_session().add(obj) DBEngine.get_session().commit() return True
def add(self, obj: Meal): if self.get(obj.JidloID): return False DBEngine.get_session().add(obj) DBEngine.get_session().commit() return True
def get_all(self): addresses = DBEngine.get_session().query(Address).all() return addresses
def get_all(self): tables = DBEngine.get_session().query(Table).all() return tables