-
Notifications
You must be signed in to change notification settings - Fork 491
Expand file tree
/
Copy pathSpaDayController.java
More file actions
72 lines (64 loc) · 2.66 KB
/
SpaDayController.java
File metadata and controls
72 lines (64 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package org.launchcode.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
@Controller
public class SpaDayController {
public boolean checkSkinType(String skinType, String facialType) {
if (skinType.equals("oily")) {
return facialType.equals("Microdermabrasion") || facialType.equals("Rejuvenating");
}
else if (skinType.equals("combination")) {
return facialType.equals("Microdermabrasion") || facialType.equals("Rejuvenating") || facialType.equals("Enzyme Peel");
}
else if (skinType.equals("dry")) {
return facialType.equals("Rejuvenating") || facialType.equals("Hydrofacial");
}
else {
return true;
}
}
@GetMapping(value="")
@ResponseBody
public String customerForm () {
String html = "<form method = 'post'>" +
"Name: <br>" +
"<input type = 'text' name = 'name'>" +
"<br>Skin type: <br>" +
"<select name = 'skintype'>" +
"<option value = 'oily'>Oily</option>" +
"<option value = 'combination'>Combination</option>" +
"<option value = 'normal'>Normal</option>" +
"<option value = 'dry'>Dry</option>" +
"</select><br>" +
"Manicure or Pedicure? <br>" +
"<select name = 'manipedi'>" +
"<option value = 'manicure'>Manicure</option>" +
"<option value = 'pedicure'>Pedicure</option>" +
"</select><br>" +
"<input type = 'submit' value = 'Submit'>" +
"</form>";
return html;
}
@PostMapping(value="")
public String spaMenu(@RequestParam String name, @RequestParam String skintype, @RequestParam String manipedi, Model model) {
ArrayList<String> facials = new ArrayList<>();
facials.add("Microdermabrasion");
facials.add("Hydrofacial");
facials.add("Rejuvenating");
facials.add("Enzyme Peel");
ArrayList<String> appropriateFacials = new ArrayList<>();
for (int i = 0; i < facials.size(); i ++) {
if (checkSkinType(skintype,facials.get(i))) {
appropriateFacials.add(facials.get(i));
}
}
model.addAttribute("name" , name);
model.addAttribute("skintype", skintype);
model.addAttribute("facials", facials);
model.addAttribute("appropriateFacials", appropriateFacials);
model.addAttribute("manipedi", manipedi);
return "menu";
}
}