-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathSpaDayController.java
More file actions
85 lines (72 loc) · 3.04 KB
/
SpaDayController.java
File metadata and controls
85 lines (72 loc) · 3.04 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
73
74
75
76
77
78
79
80
81
82
83
84
85
package org.launchcode.spaday.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' action='menu'>" +
"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>" +
"<option value = 'both'>Mani/Pedi</option>" +
"</select><br>" +
"<input type = 'submit' value = 'Submit'>" +
"</form>";
return html;
}
@PostMapping(value="/menu")
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));
}
}
ArrayList<String> polishChoices = new ArrayList<>();
polishChoices.add("#000000");
polishChoices.add("#162252");
polishChoices.add("#2E0854");
polishChoices.add("#8B3626");
polishChoices.add("#A02422");
polishChoices.add("#E79EA9");
model.addAttribute("polishChoices", polishChoices);
model.addAttribute("name", name);
model.addAttribute("skintype",skintype);
model.addAttribute("manipedi", manipedi);
model.addAttribute("appropriateFacials", appropriateFacials);
return "menu";
}
}