package com.plannaplan.services; import java.util.List; import java.util.Optional; import com.plannaplan.entities.Course; import com.plannaplan.repositories.CourseRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class CourseService { @Autowired private CourseRepository repo; public Optional getCourseByName(String name) { return this.repo.findByName(name); } public List getAllCourses() { return this.repo.findAll(); } public Course save(Course course) { this.repo.save(course); return course; } public void delete(Course course) { this.repo.delete(course); } public int getCoursesAmmount() { return (int) this.repo.count(); } }