Skip to content
Snippets Groups Projects
Commit bf8d24cb authored by Rhys Nute's avatar Rhys Nute
Browse files

updated

parent 9cafb6a5
No related branches found
No related tags found
1 merge request!39Draft: Towns
...@@ -55,3 +55,18 @@ public class LandmarksController { ...@@ -55,3 +55,18 @@ public class LandmarksController {
} }
@Autowired
private localAuthorityRepository localAuthorityRepository;
@PostMapping("/local-auth-data1")
public ModelAndView localAuthSent(@Valid @ModelAttribute("localAuthority")localAuthority localAuthority, BindingResult bindingResult, Model model ) {
if (bindingResult.hasErrors()){
ModelAndView modelAndView = new ModelAndView("local-auth-data.html", model.asMap());
return modelAndView;
}else{// converts user input using the organisation constructor into a submittable format to the sql table
localAuthority loc = new localAuthority(localAuthority.getLocalAuthorityName(), localAuthority.getAddress1(), localAuthority.getAddress2(), localAuthority.getCity(), localAuthority.getCounty(), localAuthority.getPostcode(), localAuthority.getWebsite());
System.out.println(loc);
localAuthorityRepository.addLocalAuthority(loc); //add local authority to local authority table
ModelAndView modelAndView = new ModelAndView("redirect:/local-authorities");
return modelAndView;
}
...@@ -58,14 +58,14 @@ public class organisationControllers { ...@@ -58,14 +58,14 @@ public class organisationControllers {
List<addAddTowns> addtowns = addAddTownsRepository.getAllAddTowns(); List<addAddTowns> addtowns = addAddTownsRepository.getAllAddTowns();
if (bindingResult.hasErrors()) { if (bindingResult.hasErrors()) {
ModelAndView modelAndView = new ModelAndView("towns-data", model.asMap()); ModelAndView modelAndView = new ModelAndView("towns-data.html", model.asMap());
return modelAndView; return modelAndView;
} else {// converts user input using the organisation constructor into a submittable format to the sql table } else {// converts user input using the organisation constructor into a submittable format to the sql table
addAddTowns tow = new addAddTowns(towns.getTownName(), towns.getAddress1(), towns.getAddress2(), towns.getCity(), towns.getCounty(), towns.getPostcode()); addAddTowns tow = new addAddTowns(towns.getTownName(), towns.getAddress1(), towns.getAddress2(), towns.getCity(), towns.getCounty(), towns.getPostcode());
System.out.println(tow); System.out.println(tow);
addAddTownsRepository.addTown(tow); //add new towns to Add Towns table addAddTownsRepository.addTown(tow); //add new towns to Add Towns table
ModelAndView modelAndView = new ModelAndView("redirect:/businesses"); ModelAndView modelAndView = new ModelAndView("redirect:/towns");
return modelAndView; return modelAndView;
} }
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Towns</title> <title>Towns</title>
<link rel="stylesheet" th:href="@{css/addTownsPageStyle.css}"> <link rel="stylesheet" th:href="@{css/landmarkFormStyle.css}">
<link rel="stylesheet" th:href="@{css/templatingstyle.css}"> <link rel="stylesheet" th:href="@{css/templatingstyle.css}">
</head> </head>
<header th:insert="~{/towns/Templating.html::header}"></header> <header th:insert="~{/towns/Templating.html::header}"></header>
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<li th:text="${towns}"></li> <li th:text="${towns}"></li>
</ul> </ul>
</div> </div>
<a href="/townForm"><button id="submit">Towns log in here</button></a> <a href="/townsForm"><button id="submit">Towns log in here</button></a>
</body> </body>
<footer th:insert="~{/towns/Templating.html::footer}"></footer> <footer th:insert="~{/towns/Templating.html::footer}"></footer>
</html> </html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment