def post_employee_course(empid): try: course_ = Courses.json_parse(request.json) CourseService.create_courses(course_, empid) return jsonify(course_.json()), 201 except ValueError as e: return "Not a valid ID or No such user exist with this ID", 400 # Bad Request
def update_course(empid, courseid): # try: emp = EmployeeService.get_employee(int(empid)) if emp: # print(emp) get_course = CourseService.get_course_ID(int(courseid)) if get_course: all_course = Courses.json_parse(request.json) CourseService.update_course(all_course, courseid) return jsonify(all_course.json()), 200 else: return f'Course ID {courseid} - not found', 404 else: return f'Employee ID {emp} - not found', 404