@@ -305,6 +305,48 @@ public String taxZoneWithZoneIdDeletePerform(@PathVariable long taxZoneId, @Path
305305 return "redirect:/admin/taxZone/" +taxZoneId ;
306306 }
307307
308+ @ RequestMapping (value = "/admin/taxZone/{taxZoneId}/zone/{zoneId}/edit" , method = RequestMethod .GET )
309+ public String taxZoneWithZoneIdEditForm (@ PathVariable long taxZoneId , @ PathVariable long zoneId ,Model model ){
310+ int menuCategory = AdminMenuCategory .LOCATION_TAXES .ordinal ();
311+ model .addAttribute ("menuCategory" ,menuCategory );
312+ TaxZone thisTaxZone = adminService .findTaxZoneById (taxZoneId );
313+ model .addAttribute ("thisTaxZone" ,thisTaxZone );
314+ List <TaxZone2Zone > zones = adminService .findZonesByTaxZone (thisTaxZone );
315+ model .addAttribute ("zones" ,zones );
316+ TaxZone2Zone thisZone = adminService .findTaxZone2ZoneById (zoneId );
317+ model .addAttribute ("thisZone" ,thisZone );
318+ return "admin/taxZoneEditForm" ;
319+ }
320+
321+ @ RequestMapping (value = "/admin/taxZone/{taxZoneId}/zone/{zoneId}/edit" , method = RequestMethod .POST )
322+ public String taxZoneWithZoneIdEditPerform (@ PathVariable long taxZoneId ,
323+ @ PathVariable long zoneId ,
324+ @ ModelAttribute NewSubZoneInfoBean newSubZoneInfoBean ,
325+ BindingResult result ,
326+ Model model ){
327+ TaxZone2Zone thisZone = adminService .findTaxZone2ZoneById (zoneId );
328+ if (result .hasErrors ()||newSubZoneInfoBean .getZone_country_id ()==null ) {
329+ int menuCategory = AdminMenuCategory .LOCATION_TAXES .ordinal ();
330+ model .addAttribute ("menuCategory" ,menuCategory );
331+ TaxZone thisTaxZone = adminService .findTaxZoneById (taxZoneId );
332+ model .addAttribute ("thisTaxZone" ,thisTaxZone );
333+ List <TaxZone2Zone > zones = adminService .findZonesByTaxZone (thisTaxZone );
334+ model .addAttribute ("zones" ,zones );
335+ model .addAttribute ("thisZone" ,thisZone );
336+ return "admin/taxZoneEditForm" ;
337+ } else {
338+ Country country = customerService .findCountryById (newSubZoneInfoBean .getZone_country_id ());
339+ Zone subZone = null ;
340+ if (newSubZoneInfoBean .getZone_id ()!=null ){
341+ subZone = customerService .findZoneById (newSubZoneInfoBean .getZone_id ());
342+ }
343+ thisZone .setZoneCountry (country );
344+ thisZone .setZone (subZone );
345+ adminService .updateTaxZone2Zone (thisZone );
346+ return "redirect:/admin/taxZone/" +taxZoneId +"/zone/" +zoneId ;
347+ }
348+ }
349+
308350 @ RequestMapping (value = "/admin/taxClasses" , method = RequestMethod .GET )
309351 public String taxClasses (Model model ){
310352 int menuCategory = AdminMenuCategory .LOCATION_TAXES .ordinal ();
0 commit comments