Skip to content
Snippets Groups Projects

Draft: Towns

Closed Rhys Nute requested to merge towns into main
Files
3
@@ -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;
}
Loading