async def update_movie(id: int, payload: MovieIn): movie = await db_manager.get_movie(id) if not movie: raise HTTPException(status_code=404, detail="Movie not found") update_data = payload.dict(exclude_unset=True) movie_in_db = MovieIn(**movie) updated_movie = movie_in_db.copy(update=update_data) return await db_manager.update_movie(id, updated_movie)
async def update_movie(id: int, payload: MovieUpdate): movie = await db_manager.get_movie(id) if not movie: raise HTTPException(status_code=404, detail="Movie not found") update_data = payload.dict(exclude_unset=True) if 'casts_id' in update_data: for cast_id in payload.casts_id: if not is_cast_present(cast_id): raise HTTPException(status_code=404, detail=f"Cast with given id:{cast_id} not found") movie_in_db = MovieIn(**movie) updated_movie = movie_in_db.copy(update=update_data) return await db_manager.update_movie(id, updated_movie)