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

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;

import at.ac.tuwien.inso.entity.Course;
import at.ac.tuwien.inso.entity.Lecturer;
import at.ac.tuwien.inso.service.CourseService;
import at.ac.tuwien.inso.service.LecturerService;

@Controller
@RequestMapping("/lecturer/courses")
public class LecturerCoursesController {

    @Autowired
    private CourseService courseService;
    @Autowired
    private LecturerService lecturerService;


    @ModelAttribute("allCourses")
    private List<Course> getAllCourses() {
        Lecturer lecturer = lecturerService.getLoggedInLecturer();
        return courseService.findCoursesForCurrentSemesterForLecturer(lecturer);
    }

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

@@ -41,16 +41,98 @@
 turer;%0A%0A
+import at.ac.tuwien.inso.entity.Tag;%0Aimport at.ac.tuwien.inso.service.TagService;%0A
 import o
@@ -186,16 +186,16 @@
 owired;%0A
-
 import o
@@ -280,79 +280,8 @@
 n.*;
-%0Aimport org.springframework.web.servlet.mvc.support.RedirectAttributes;
 %0A%0Aim
@@ -690,16 +690,66 @@
 ervice;%0A
+    @Autowired%0A    private TagService tagService;%0A
 %0A%0A    @M
@@ -1012,32 +1012,32 @@
 ing courses() %7B%0A
-
         return %22
@@ -1060,11 +1060,399 @@
 %22;%0A    %7D
+%0A%0A    @GetMapping(%22json/tags%22)%0A    @ResponseBody%0A    private List%3CTag%3E getTagsJson() %7B%0A        return tagService.findAll();%0A    %7D%0A%0A    @GetMapping(value = %22json/tags%22, params = %22courseId%22)%0A    @ResponseBody%0A    private List%3CTag%3E getTagsForCourseJson(@RequestParam(%22courseId%22) Long courseId) %7B%0A        Course course = courseService.findOne(courseId);%0A        return course.getTags();%0A    %7D
 %0A%7D%0A

add rest endpoints for the tags.