File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -276,6 +276,22 @@ async def delete_camera(camera_id: int):
276276 status_code = status .HTTP_500_INTERNAL_SERVER_ERROR ,
277277 detail = f"Internal server error: { str (e )} "
278278 )
279+
280+ @self .app .delete ("/zones/{zone_id}" )
281+ async def delete_zone (zone_id : int ):
282+ try :
283+ if self .db_manager .delete_zone (zone_id ) == False :
284+ raise HTTPException (
285+ status_code = status .HTTP_404_NOT_FOUND ,
286+ detail = f"Zone with id { zone_id } doesn't exist"
287+ )
288+ except HTTPException :
289+ raise
290+ except Exception as e :
291+ raise HTTPException (
292+ status_code = status .HTTP_500_INTERNAL_SERVER_ERROR ,
293+ detail = f"Internal server error: { str (e )} "
294+ )
279295
280296 @self .app .get ("/cameras/{camera_id}/snapshot" )
281297 async def get_camera_snapshot (camera_id : int ):
Original file line number Diff line number Diff line change @@ -371,4 +371,16 @@ def delete_camera(self, camera_id):
371371
372372 session .commit ()
373373
374+ return True
375+
376+ def delete_zone (self , zone_id ):
377+ with self .get_session () as session :
378+ res = session .query (ParkingZone ).filter (ParkingZone .id == zone_id ).first ()
379+
380+ if res is None : return False
381+
382+ session .delete (res )
383+
384+ session .commit ()
385+
374386 return True
You can’t perform that action at this time.
0 commit comments