1 | package com.example.villadihovo.web.controller.ControllersForAllReservations;
|
---|
2 |
|
---|
3 | import com.example.villadihovo.dto.ReservationForActivityDto;
|
---|
4 | import com.example.villadihovo.model.statistics.StatisticsForActivity;
|
---|
5 | import com.example.villadihovo.service.reservation.ReservationForActivityService;
|
---|
6 | import com.example.villadihovo.service.statistics.StatisticsForActivityService;
|
---|
7 | import lombok.AllArgsConstructor;
|
---|
8 | import org.springframework.beans.factory.annotation.Autowired;
|
---|
9 | import org.springframework.stereotype.Controller;
|
---|
10 | import org.springframework.ui.Model;
|
---|
11 | import org.springframework.web.bind.annotation.GetMapping;
|
---|
12 | import org.springframework.web.bind.annotation.RequestMapping;
|
---|
13 | import org.springframework.web.bind.annotation.RestController;
|
---|
14 | import org.springframework.web.servlet.ModelAndView;
|
---|
15 |
|
---|
16 | import java.util.List;
|
---|
17 |
|
---|
18 | @Controller
|
---|
19 | @RequestMapping("/reservations/activity")
|
---|
20 | public class ActivityReservationsController {
|
---|
21 | @Autowired
|
---|
22 | private ReservationForActivityService reservationForActivityService;
|
---|
23 | @Autowired
|
---|
24 | private StatisticsForActivityService statistics;
|
---|
25 |
|
---|
26 | @GetMapping
|
---|
27 | public String listAllActivityReservations(Model model){
|
---|
28 | List<ReservationForActivityDto> allActivityReservations = this.reservationForActivityService.findAllActivityReservations();
|
---|
29 | model.addAttribute("activityReservations", allActivityReservations);
|
---|
30 | return "activity-reservations";
|
---|
31 | }
|
---|
32 |
|
---|
33 | @GetMapping("/statistics")
|
---|
34 | public String listAllActivitiesAndStatistics(Model model){
|
---|
35 | List<ReservationForActivityDto> allActivityReservations = this.reservationForActivityService.findAllActivityReservations();
|
---|
36 | List<StatisticsForActivity> statistics = this.statistics.listAll();
|
---|
37 | model.addAttribute("activityReservations", allActivityReservations);
|
---|
38 | model.addAttribute("statistics", statistics);
|
---|
39 | return "activity-statistics";
|
---|
40 | }
|
---|
41 |
|
---|
42 |
|
---|
43 |
|
---|
44 | }
|
---|