error enchere
This commit is contained in:
@@ -43,7 +43,9 @@ public class EnchereController {
|
||||
|
||||
//Empeche une enchere inférieur au prix de base de l'article
|
||||
Article article = this.articleService.findArticleById(articleId);
|
||||
if (enchere.getMontantEnchere() < article.getPrixInitial()) {
|
||||
float articlePrice = article.getPrixInitial();
|
||||
float encherePrice = enchere.getMontantEnchere();
|
||||
if (encherePrice < articlePrice) {
|
||||
result.rejectValue("montantEnchere", "error.enchere", "Vous ne pouvez pas enchérir un montant inférieur au prix initial");
|
||||
}
|
||||
|
||||
@@ -53,10 +55,14 @@ public class EnchereController {
|
||||
.map(Enchere::getMontantEnchere) // Récupère seulement les montants d'enchère
|
||||
.max(Float::compareTo);
|
||||
System.out.println(maxMontantEnchere);
|
||||
if (enchere.getMontantEnchere() < maxMontantEnchere.get()) {
|
||||
if (maxMontantEnchere.isPresent() && encherePrice < maxMontantEnchere.get()) {
|
||||
result.rejectValue("montantEnchere", "error.enchere", "Vous ne pouvez pas enchérir un montant inférieur à la dernière enchère");
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
return "redirect:/article/show?id=" + articleId;
|
||||
}
|
||||
|
||||
this.enchereService.setEnchere(enchere);
|
||||
return "redirect:/article/show?id=" + articleId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user