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

completed database

parent 0822ee82
No related branches found
No related tags found
1 merge request!39Draft: Towns
...@@ -33,4 +33,19 @@ public class organisationControllers { ...@@ -33,4 +33,19 @@ public class organisationControllers {
ModelAndView modelAndView = new ModelAndView("WorkWith/towns.html"); ModelAndView modelAndView = new ModelAndView("WorkWith/towns.html");
return modelAndView; return modelAndView;
} }
@Autowired
private addAddTownsRepository addAddTownsRepository;
@PostMapping("/townssub")
public ModelAndView townsSent(@Valid @ModelAttribute("towns-data")Towns towns, BindingResult bindingResult, Model model ) {
if (bindingResult.hasErrors()) {
ModelAndView modelAndView = new ModelAndView("towns-data", model.asMap());
return modelAndView;
} else {// converts user input using the organisation constructor into a submittable format to the sql table
Towns tow= new Towns(towns.getTownName(), towns.getAddress1(), towns.getAddress2(), towns.getCity(), towns.getCounty(), towns.getPostcode());
System.out.println(bus);
addAddTownsRepository.addAddTown(tow); //add new towns to Add Towns table
ModelAndView modelAndView = new ModelAndView("redirect:/businesses");
return modelAndView;
}
} }
...@@ -11,6 +11,11 @@ ...@@ -11,6 +11,11 @@
<p>Giving local businesses a voice in the community</p> <p>Giving local businesses a voice in the community</p>
<h1>Empowering Community Spirit</h1> <h1>Empowering Community Spirit</h1>
<h1>Creating the towns Identity</h1> <h1>Creating the towns Identity</h1>
<div>
<ul th:each="addAddTowns:${addTown}">
<li th:text="${addAddTowns}"></li>
</ul>
</div>
<button id="submit">Towns log in here</button><a href="towns-data.html"></a> <button id="submit">Towns log in here</button><a href="towns-data.html"></a>
</body> </body>
<footer th:insert="~{/towns/Templating.html::footer}"></footer> <footer th:insert="~{/towns/Templating.html::footer}"></footer>
......
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