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 {
}
@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 {
List<addAddTowns> addtowns = addAddTownsRepository.getAllAddTowns();
if (bindingResult.hasErrors()) {
ModelAndView modelAndView = new ModelAndView("towns-data", model.asMap());
ModelAndView modelAndView = new ModelAndView("towns-data.html", model.asMap());
return modelAndView;
} 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());
System.out.println(tow);
addAddTownsRepository.addTown(tow); //add new towns to Add Towns table
ModelAndView modelAndView = new ModelAndView("redirect:/businesses");
ModelAndView modelAndView = new ModelAndView("redirect:/towns");
return modelAndView;
}
}
......
......@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<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}">
</head>
<header th:insert="~{/towns/Templating.html::header}"></header>
......@@ -16,7 +16,7 @@
<li th:text="${towns}"></li>
</ul>
</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>
<footer th:insert="~{/towns/Templating.html::footer}"></footer>
</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