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 java.util.List;

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

    @Autowired
    private CoursesService coursesService;

    @ModelAttribute("allCourses")
    private List<Course> getAllCourses() {
        return coursesService.findForCurrentSemester();
    }

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

@@ -283,16 +283,87 @@
 ation.*;
+%0Aimport org.springframework.web.servlet.mvc.support.RedirectAttributes;
 %0A%0Aimport
@@ -597,27 +597,151 @@
 tAllCourses(
-) %7B
+@RequestParam(value = %22search%22, required = false) String search) %7B%0A        final String searchString = getSearchString(search);
 %0A        ret
@@ -763,16 +763,22 @@
 ice.find
+Course
 ForCurre
@@ -787,18 +787,291 @@
 Semester
-()
+WithName(searchString);%0A    %7D%0A%0A    @ModelAttribute(%22searchString%22)%0A    private String getSearchString(@RequestParam(value = %22search%22, required = false) String search) %7B%0A        if (search != null && !search.isEmpty()) %7B%0A            return search;%0A        %7D%0A%0A        return %22%22
 ;%0A    %7D%0A
@@ -1152,16 +1152,17 @@
 urses%22;%0A
-
     %7D%0A
+%0A
 %7D%0A

Add search string, filter for name