Beispiel #1
0
async def delete_student_data(id: str):
    deleted_student = await delete_student(id)
    if deleted_student:
        return ResponseModel("Student with ID: {} removed".format(id),
                             "Student deleted successfully")
    return ErrorResponseModel("An error occurred", 404,
                              "Student with id {0} doesn't exist".format(id))
Beispiel #2
0
async def get_student_data(id):
    student = await retrieve_student(id)
    if student:
        return ResponseModel(student, 200,
                             "Student data retrieved successfully")
    return ErrorResponseModel("An error occurred.", 404,
                              "Student doesn't exist.")
Beispiel #3
0
async def delete_student_data(id: str):
    deleted_student = await delete_student(id)
    if deleted_student:
        return ResponseModel(f'Student with ID:{id} removed',
                             'Student deleted successfully')
    return ErrorResponseModel('An error occurred', 404,
                              'Student with ID: {0} does not exist'.format(id))
Beispiel #4
0
async def update_student_data(id: str, request: UpdateStudentModel = Body(...)):
    request = {k: v for k,v in request.dict().items() if v is not None}
    updated_student = await update_student(id, request)
    if updated_student:
        return ResponseModel(
            f"Student with ID: {id} name is updated successfully",
            "Success"
        )
    return ErrorResponseModel("An error occured", 404, "Something went wrong")
Beispiel #5
0
async def update_student_data(id: str, req: UpdateStudentModel = Body(...)):
    req = {k: v for k, v in req.dict().items() if v is not None}
    updated_student = await update_student(id, req)
    if updated_student:
        return ResponseModel(
            f'Student with ID:{id} name update is successful ',
            'Student name updated successfully')
    return ErrorResponseModel('An error occuered', 404,
                              'There was an error updating the student data')
Beispiel #6
0
async def delete_student_data(id: str):
    deleted_student = await delete_student(id)
    if deleted_student:
        return ResponseModel(
            f"Student with ID: {id} is deleted successfully",
            "Success"
        )
    return ErrorResponseModel(
        "An error occurred", 404, f"Student with ID: {id} does not exist"
    )
Beispiel #7
0
async def update_student_data(id: str, req: UpdateStudentModel = Body(...)):
    req = {k: v for k, v in req.dict().items() if v is not None}
    updated_student = await update_student(id, req)
    if updated_student:
        return ResponseModel(
            "Student with ID: {} name update is successful".format(id),
            "Student name updated successfully",
        )
    return ErrorResponseModel(
        "An error occurred",
        404,
        "There was an error updating the student data.",
    )
Beispiel #8
0
async def get_student(id):
    student = await retrieve_student(id)
    if student:
        return ResponseModel(student, "Studend data retrieved successfully")
    return ErrorResponseModel("An error occured", 404, "There is no student with that id")
Beispiel #9
0
async def get_student_data(id):
    student = await retrieve_student(id)
    if student:
        return ResponseModel(student, 'Student data retrieved successfully')
    return ErrorResponseModel('An error occured.', 404,
                              'Student does not exist')