Skip to content

Commit 742f7a8

Browse files
committed
(TP-123) feat: add renter rents his own property check
1 parent 78f41c0 commit 742f7a8

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

rentplace/src/main/java/kattsyn/dev/rentplace/services/impl/ReservationServiceImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ public ReservationDTO getReservationDTOById(long reservationId) {
8888
@Transactional
8989
public ReservationDTO createReservation(ReservationCreateEditDTO reservationCreateEditDTO) {
9090
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+
9197
setPrices(reservation);
9298
reservation.setPaymentStatus(PaymentStatus.NOT_PAID);
9399

0 commit comments

Comments
 (0)