def create_episode_in_show(name): request_data = request.get_json() parent = show.ShowModel.find_by_name(name) if parent: new_episode = episode.EpisodeModel(name=request_data['name'], season=request_data['season'], show_id=parent.id) new_episode.save_to_db() return new_episode.json() else: return {'message': 'Serie não encontrada'}, 404
def create_episode_in_show(id): request_data = request.get_json() for item in request_data: parent = show.ShowModel.find_by_id(id) if parent: new_episode = episode.EpisodeModel(name=item["name"], season=item["season"], show_id=parent.id) new_episode.save_to_db() # return new_episode.json() else: return {"message": "Série não encontrada"}, 404 return show.ShowModel.find_by_id(id).json()