We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 78f41c0 commit 742f7a8Copy full SHA for 742f7a8
1 file changed
rentplace/src/main/java/kattsyn/dev/rentplace/services/impl/ReservationServiceImpl.java
@@ -88,6 +88,12 @@ public ReservationDTO getReservationDTOById(long reservationId) {
88
@Transactional
89
public ReservationDTO createReservation(ReservationCreateEditDTO reservationCreateEditDTO) {
90
Reservation reservation = reservationMapper.fromReservationCreateEditDTO(reservationCreateEditDTO);
91
+
92
+ if (reservation.getRenter().getUserId() == reservation.getProperty().getOwner().getUserId()) {
93
+ throw new ValidationException(String.format("Owner id: %s can't rent his own property id: %s",
94
+ reservationCreateEditDTO.getRenterId(), reservationCreateEditDTO.getPropertyId()));
95
+ }
96
97
setPrices(reservation);
98
reservation.setPaymentStatus(PaymentStatus.NOT_PAID);
99
0 commit comments