[204464d] | 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.beans.factory.annotation.Autowired;
|
---|
| 6 | import org.springframework.http.MediaType;
|
---|
| 7 | import org.springframework.stereotype.Controller;
|
---|
| 8 | import org.springframework.ui.Model;
|
---|
| 9 | import org.springframework.web.bind.annotation.GetMapping;
|
---|
| 10 | import org.springframework.web.bind.annotation.ModelAttribute;
|
---|
| 11 | import org.springframework.web.bind.annotation.PostMapping;
|
---|
| 12 |
|
---|
| 13 | @Controller
|
---|
| 14 | public class RegisterController {
|
---|
| 15 |
|
---|
| 16 | private final StakeholderService stakeholderService;
|
---|
| 17 |
|
---|
| 18 | public RegisterController(StakeholderService stakeholderService) {
|
---|
| 19 | this.stakeholderService = stakeholderService;
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | @GetMapping("/register_customer")
|
---|
| 23 | public String getCustomerRegisterPage(Model model) {
|
---|
| 24 | model.addAttribute("stakeholder", new Stakeholder());
|
---|
| 25 | return "register_customer";
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | @PostMapping(value = "/register_customer")
|
---|
| 29 | public String registerCustomer(@ModelAttribute Stakeholder customer, Model model) {
|
---|
| 30 | Stakeholder user = stakeholderService.saveStakeholder(customer);
|
---|
| 31 | model.addAttribute("user", user);
|
---|
| 32 | return "homepage";
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | @GetMapping("/register_business")
|
---|
| 36 | public String getBusinessRegisterPage(Model model) {
|
---|
| 37 | return "register_business";
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | @PostMapping("/register_business")
|
---|
| 41 | public String registerBusiness(Model model) {
|
---|
| 42 | return "register_business";
|
---|
| 43 | }
|
---|
| 44 | }
|
---|