package at.ac.tuwien.inso.controller.student;

import at.ac.tuwien.inso.entity.Course;
import at.ac.tuwien.inso.service.CoursesService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import java.util.List;

@Controller
@RequestMapping("/student/courses")
public class StudentCoursesController {

    @Autowired
    private CoursesService coursesService;

    @ModelAttribute("allCourses")
    private List<Course> getAllCourses(@RequestParam(value = "search", required = false) String search) {
        final String searchString = getSearchString(search);
        return coursesService.findCourseForCurrentSemesterWithName(searchString);
    }

    @ModelAttribute("searchString")
    private String getSearchString(@RequestParam(value = "search", required = false) String search) {
        if (search != null && !search.isEmpty()) {
            return search;
        }

        return "";
    }

    @GetMapping
    public String courses() {
        return "/student/courses";
    }

}

@@ -115,25 +115,24 @@
 rvice.Course
-s
 Service;%0A%0Aim
@@ -128,16 +128,16 @@
 ervice;%0A
+
 %0Aimport 
@@ -286,79 +286,8 @@
 n.*;
-%0Aimport org.springframework.web.servlet.mvc.support.RedirectAttributes;
 %0A%0Aim
@@ -426,25 +426,24 @@
 ivate Course
-s
 Service cour
@@ -440,25 +440,24 @@
 rvice course
-s
 Service;%0A%0A  
@@ -655,16 +655,16 @@
 earch);%0A
+
         
@@ -676,17 +676,16 @@
 n course
-s
 Service.

Refactor name of CourseService