From 55e1ae9384439d35faf4824c1a3d2894ab1e84c0 Mon Sep 17 00:00:00 2001 From: Nelson Date: Tue, 16 Nov 2021 14:47:32 -0300 Subject: [PATCH] validacion de que no hayan fechas solapadas al crear una nueva convocatoria --- curriculumsearch/src/main/java/com/roshka/controller/ConvocatoriaController.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/curriculumsearch/src/main/java/com/roshka/controller/ConvocatoriaController.java b/curriculumsearch/src/main/java/com/roshka/controller/ConvocatoriaController.java index 9eec909..5e4cc89 100644 --- a/curriculumsearch/src/main/java/com/roshka/controller/ConvocatoriaController.java +++ b/curriculumsearch/src/main/java/com/roshka/controller/ConvocatoriaController.java @@ -70,17 +70,19 @@ public class ConvocatoriaController { } @PostMapping(path = {"/convocatoria","/convocatoria/{id}"}) - public String guardarConvocatoria(@ModelAttribute ConvocatoriaCargo convocatoria, BindingResult result, @PathVariable(required = false) Long id) { + public String guardarConvocatoria(@ModelAttribute ConvocatoriaCargo convocatoria, BindingResult result, @PathVariable(required = false) Long id,Model model) { if(result.hasErrors()); if(id != null) convocatoria.setId(id); //System.out.println(convoRepo.filtrarConvocatoriasPorCargo(convocatoria.getCargoId())); for(ConvocatoriaCargo c: convoRepo.filtrarConvocatoriasPorCargo(convocatoria.getCargoId())){ - if(c.getCargoId()==convocatoria.getCargoId() && c.getFechaFin().after(convocatoria.getFechaInicio()) ) - { + if(result.hasErrors() || c.getCargoId()==convocatoria.getCargoId() && c.getFechaFin().after(convocatoria.getFechaInicio()) ) + { - return "redirect:/convocatoria"; + model.addAttribute("existeFecha", true); + System.out.println("no debe"); + return "convocatoria-form"; } else{ -- libgit2 0.26.0