Class InstructorService
java.lang.Object
org.codewithmagret.rest.instructor.InstructorService
Service class for handling business logic related to instructors.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddInstructor(Instructor instructor) Adds a new instructor to the repository.booleandeleteInstructor(Long id) Deletes an instructor by its ID.Retrieves an instructor by its ID.Retrieves all instructors from the repository.updateInstructor(Long id, Instructor instructorToUpdate) Updates an existing instructor in the repository.
-
Constructor Details
-
InstructorService
public InstructorService()Default constructor for InstructorService.
-
-
Method Details
-
getInstructors
Retrieves all instructors from the repository.- Returns:
- a list of all instructors
-
getInstructorById
Retrieves an instructor by its ID.- Parameters:
id- the ID of the instructor to retrieve- Returns:
- the Instructor object if found, or null if not found
-
addInstructor
Adds a new instructor to the repository.- Parameters:
instructor- the Instructor object to add- Returns:
- the saved Instructor object
-
updateInstructor
Updates an existing instructor in the repository.- Parameters:
id- the ID of the instructor to updateinstructorToUpdate- the Instructor object containing the updated data- Returns:
- the updated Instructor object if found, or null if not found
-
deleteInstructor
Deletes an instructor by its ID.- Parameters:
id- the ID of the instructor to delete- Returns:
- true if the instructor was deleted, or false if the instructor was not found
-