Class InstructorService

java.lang.Object
org.codewithmagret.rest.instructor.InstructorService

@Service public class InstructorService extends Object
Service class for handling business logic related to instructors.
  • Constructor Details

    • InstructorService

      public InstructorService()
      Default constructor for InstructorService.
  • Method Details

    • getInstructors

      public List<Instructor> getInstructors()
      Retrieves all instructors from the repository.
      Returns:
      a list of all instructors
    • getInstructorById

      public Instructor getInstructorById(Long id)
      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

      public Instructor addInstructor(Instructor instructor)
      Adds a new instructor to the repository.
      Parameters:
      instructor - the Instructor object to add
      Returns:
      the saved Instructor object
    • updateInstructor

      public Instructor updateInstructor(Long id, Instructor instructorToUpdate)
      Updates an existing instructor in the repository.
      Parameters:
      id - the ID of the instructor to update
      instructorToUpdate - the Instructor object containing the updated data
      Returns:
      the updated Instructor object if found, or null if not found
    • deleteInstructor

      public boolean deleteInstructor(Long id)
      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