1 | package edu.gjoko.schedlr.controllers;
|
---|
2 |
|
---|
3 | import edu.gjoko.schedlr.entity.Stakeholder;
|
---|
4 | import edu.gjoko.schedlr.services.StakeholderService;
|
---|
5 | import org.springframework.stereotype.Controller;
|
---|
6 | import org.springframework.ui.Model;
|
---|
7 | import org.springframework.web.bind.annotation.GetMapping;
|
---|
8 | import org.springframework.web.bind.annotation.ModelAttribute;
|
---|
9 | import org.springframework.web.bind.annotation.PostMapping;
|
---|
10 |
|
---|
11 | @Controller
|
---|
12 | public class RegisterController {
|
---|
13 |
|
---|
14 | private final StakeholderService stakeholderService;
|
---|
15 |
|
---|
16 | public RegisterController(StakeholderService stakeholderService) {
|
---|
17 | this.stakeholderService = stakeholderService;
|
---|
18 | }
|
---|
19 |
|
---|
20 | @GetMapping(path ="/register_customer")
|
---|
21 | public String getCustomerRegisterPage(Model model) {
|
---|
22 | model.addAttribute("stakeholder", new Stakeholder());
|
---|
23 | return "register_customer";
|
---|
24 | }
|
---|
25 |
|
---|
26 | @PostMapping(path = "/register_customer")
|
---|
27 | public String registerCustomer(@ModelAttribute Stakeholder customer, Model model) {
|
---|
28 | stakeholderService.saveStakeholder(customer);
|
---|
29 | return "redirect:login";
|
---|
30 | }
|
---|
31 |
|
---|
32 | @GetMapping(path = "/register_business")
|
---|
33 | public String getBusinessRegisterPage(Model model) {
|
---|
34 | return "register_business";
|
---|
35 | }
|
---|
36 |
|
---|
37 | @PostMapping(value = "/register_business")
|
---|
38 | public String registerBusiness(Model model) {
|
---|
39 | return "redirect:login";
|
---|
40 | }
|
---|
41 | }
|
---|