Skip to content

Commit

Permalink
Gestion du bagage: chaque voyageur peut bénéficier d'un bagage gratui…
Browse files Browse the repository at this point in the history
…t de 10Kg Max, chaque point supllémrantaire et payé au Kg
  • Loading branch information
e.elhjoujy committed Oct 25, 2023
1 parent 5611bff commit ea3b614
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public boolean ajouterReservation(ReservationEntity reservationEntity) {
for (VolEntity vol:reservationEntity.getVolEntities()){
entityManager.persist(vol);
}
entityManager.persist(reservationEntity.getBagage());
entityManager.persist(reservationEntity);
transaction.commit();
return true;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/ma/yc/airafraik/entities/ReservationEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public class ReservationEntity {
@Column(name = "cancelled")
private boolean cancelled;

@OneToOne
private BagageEntity bagage ;


@ManyToMany
@JoinTable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,13 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws S

// TODO: 25/10/2023 BAGAGE
BagageEntity bagageEntity = new BagageEntity();
double poids = Double.parseDouble(req.getParameter("poids"));
double prixPoids = Double.parseDouble(req.getParameter("poids"));
bagageEntity.setPrix(bagageService.calculerPrixBagage(prixPoids));
String poidsString = req.getParameter("poids") == null ? "0" : req.getParameter("poids");
double poids = Double.parseDouble(poidsString);
bagageEntity.setPrix(bagageService.calculerPrixBagage(poids));
bagageEntity.setPoids(poids);

reservationEntity.setPrixTotal(prixTotal + bagageEntity.getPrix());
reservationEntity.setBagage(bagageEntity);

Double prixtotal = this.reservationService.confirmationReservation(reservationEntity);

Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/reservation-confirmation-page.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

<%-- Bagage --%>
<div class="form-group">
<label for="bagage">Bagage: </label>
<label for="bagage">Bagage: (Kg)</label>
<input type="number" name="baagae" id="bagage" >
</div>

Expand Down

0 comments on commit ea3b614

Please sign in to comment.