setCredit on enchere
This commit is contained in:
@@ -67,11 +67,14 @@ public class EnchereController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (result.hasErrors()) {
|
if (result.hasErrors()) {
|
||||||
|
System.out.println(result);
|
||||||
session.setAttribute("errors", result.getAllErrors());
|
session.setAttribute("errors", result.getAllErrors());
|
||||||
return "redirect:/article/show?id=" + articleId;
|
return "redirect:/article/show?id=" + articleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.enchereService.setEnchere(enchere);
|
this.enchereService.setEnchere(enchere);
|
||||||
|
float newCredit = userCredit - enchere.getMontantEnchere();
|
||||||
|
this.userService.setCredit(newCredit, this.userService.utilisateurByName(authentication.getName()).getId());
|
||||||
return "redirect:/article/show?id=" + articleId;
|
return "redirect:/article/show?id=" + articleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,11 +55,11 @@
|
|||||||
<input type="hidden" id="articleId" name="articleId" th:value="${article.id}">
|
<input type="hidden" id="articleId" name="articleId" th:value="${article.id}">
|
||||||
<label for="montantEnchere" th:text="#{article.details.label.amount}"></label>
|
<label for="montantEnchere" th:text="#{article.details.label.amount}"></label>
|
||||||
<input type="number" th:field="*{montantEnchere}" id="montantEnchere" step="0.01" min="0">
|
<input type="number" th:field="*{montantEnchere}" id="montantEnchere" step="0.01" min="0">
|
||||||
<span style="color: red;" th:if="${#fields.hasErrors('montantEnchere')}">
|
<span style="color: red;" th:if="${errors != null}">
|
||||||
<ul>
|
<ul>
|
||||||
<li th:each="erreur: ${#fields.errors('montantEnchere')}" th:text="${erreur}"></li>
|
<li th:each="erreur: ${errors[0]}" th:text="${erreur.defaultMessage}"></li>
|
||||||
</ul>
|
</ul>
|
||||||
</span>
|
</span>
|
||||||
<button type="submit" class="btn btn-primary" th:text="#{article.details.button.bid}"></button>
|
<button type="submit" class="btn btn-primary" th:text="#{article.details.button.bid}"></button>
|
||||||
</form>
|
</form>
|
||||||
<div class="mt-5 d-flex justify-content-end align-items-center">
|
<div class="mt-5 d-flex justify-content-end align-items-center">
|
||||||
|
|||||||
Reference in New Issue
Block a user