mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-02 17:43:43 +02:00
38 lines
983 B
Java
38 lines
983 B
Java
package catering.order;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
@Controller
|
|
public class OrderController {
|
|
|
|
private final CustomOrderRepository orderRepository;
|
|
|
|
public OrderController(CustomOrderRepository orderRepository) {
|
|
this.orderRepository = orderRepository;
|
|
}
|
|
|
|
@GetMapping("/orders")
|
|
public String orders(Model model) {
|
|
model.addAttribute("orders", orderRepository.getOrders());
|
|
model.addAttribute("total", orderRepository.getOrders().size());
|
|
return "orders";
|
|
}
|
|
|
|
@GetMapping("/event")
|
|
public String event() {
|
|
return "eventPlanner";
|
|
}
|
|
|
|
@PostMapping("/orders/remove")
|
|
public String removeOrder(@RequestParam int orderID) {
|
|
orderRepository.removeOrder(orderID);
|
|
return "redirect:/orders";
|
|
}
|
|
}
|