feat: restrict license creation to only one license per adherent
This commit is contained in:
@@ -48,6 +48,12 @@ public class LicenceController {
|
||||
|
||||
Adherent adherent = adherentRepository.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid Adherent ID"));
|
||||
|
||||
List<Licence> existingLicences = licenceRepository.findByAdherentId(id);
|
||||
if (!existingLicences.isEmpty()) {
|
||||
return "redirect:/adherents/" + id + "/edit";
|
||||
}
|
||||
|
||||
Categorie categorie = categorieRepository.findById(categorieId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid Categorie ID"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user