@@ -39,46 +39,10 @@ async def delete_student_data(id: str):
39
39
else ErrorResponseModel ("An error occured" , 404 , "Student with id {0} doesn't exist" .format (id ))
40
40
41
41
42
- @router .put ("/name/ {id}" )
43
- async def update_name (id : str , req : UpdateName = Body (...)):
44
- updated_student = await update_student_name (id , req .fullname )
42
+ @router .put ("{id}" )
43
+ async def update_student (id : str , req : UpdateStudentModel = Body (...)):
44
+ updated_student = await update_student_data (id , req .dict () )
45
45
return ResponseModel ("Student with ID: {} name update is successful" .format (id ),
46
- "Student name updated succeasfully " ) \
46
+ "Student name updated successfully " ) \
47
47
if updated_student \
48
- else ErrorResponseModel ("An error occured" , 404 , "Student with id {0} doesn't exist." .format (id ))
49
-
50
-
51
- @router .put ("/email/{id}" )
52
- async def update_email (id : str , req : UpdateEmail = Body (...)):
53
- updated_email = await update_student_email (id , req .email )
54
- return ResponseModel ("Student with ID: {} email update is successful" .format (id ),
55
- "Student email updated succeasfully" ) \
56
- if updated_email \
57
- else ErrorResponseModel ("An error occured" , 404 , "Student with id {0} doesn't exist." .format (id ))
58
-
59
-
60
- @router .put ("/course/{id}" )
61
- async def update_course (id : str , req : UpdateCourse = Body (...)):
62
- updated_course = await update_student_course (id , req .course )
63
- return ResponseModel ("Student with ID: {} course update is successful" .format (id ),
64
- "Student course updated succeasfully" ) \
65
- if updated_course \
66
- else ErrorResponseModel ("An error occured" , 404 , "Student with id {0} doesn't exist." .format (id ))
67
-
68
-
69
- @router .put ("/year/{id}" )
70
- async def update_year (id : str , req : UpdateYear = Body (...)):
71
- updated_year = await update_student_year (id , req .year )
72
- return ResponseModel ("Student with ID: {} year update is successful" .format (id ),
73
- "Student year updated succeasfully" ) \
74
- if updated_year \
75
- else ErrorResponseModel ("An error occured" , 404 , "Student with id {0} doesn't exist." .format (id ))
76
-
77
-
78
- @router .put ("/gpa/{id}" )
79
- async def update_gpa (id : str , req : UpdateGpa = Body (...)):
80
- updated_gpa = await update_student_gpa (id , req .gpa )
81
- return ResponseModel ("Student with ID: {} GPA update is successful" .format (id ),
82
- "Student GPA updated succeasfully" ) \
83
- if updated_gpa \
84
- else ErrorResponseModel ("An error occured" , 404 , "Student with id {0} doesn't exist." .format (id ))
48
+ else ErrorResponseModel ("An error occurred" , 404 , "There was an error updating the student." .format (id ))
0 commit comments