- Timestamp:
- 02/10/22 11:13:18 (2 years ago)
- Branches:
- master
- Children:
- ccb2d72
- Parents:
- 0c049e9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/app/src/main/java/parkup/services/ParkingSessionService.java
r0c049e9 rad4da86 41 41 return parkingSessionRepository.findAll().stream() 42 42 .filter(s->!s.getStatus().equals(SessionStatus.ENDED_PAID)) 43 .collect(Collectors.toList()); 44 } 45 46 public List<ParkingSession> getAllParkingSessionsFromZone(Integer pzId) { 47 //Get all sessions that arent paid 48 49 return parkingSessionRepository.findAll().stream() 50 .filter(s->!s.getStatus().equals(SessionStatus.ENDED_PAID) && s.getParkingZone().getId()==pzId) 43 51 .collect(Collectors.toList()); 44 52 } … … 92 100 throw new IllegalStateException("No such session exists"); 93 101 } 94 else if(session.getStatus()== SessionStatus.ENDED_UNPAID){95 throw new IllegalStateException("Cannot calculate payment on an ended session");96 }102 // else if(session.getStatus()!= SessionStatus.ENDED_PAID){ 103 // throw new IllegalStateException("Cannot calculate payment on a paid session"); 104 // } 97 105 int price = session.getParkingZone().getPrice(); 98 return (int) (Math.ceil(Duration.between(session.getTime End(),session.getTimeStart()).toMinutes()/60.0)*price);106 return (int) (Math.ceil(Duration.between(session.getTimeStart(),session.getTimeEnd()).toMinutes()/60.0)*price); 99 107 } 100 108 @Transactional … … 111 119 if(!parkingZone.getParkingSpaces().contains(parkingSpaceRepository.findByPsName(parkingSpaceName))){ 112 120 throw new IllegalStateException("Ivalid parking space inserted. Type in a new parking space or let the admin know that they should add the parking space to this zone"); 121 } 122 if(parkingSpaceRepository.findByPsName(parkingSpaceName).isTaken()){ 123 throw new IllegalStateException("Ivalid parking space inserted. Type in a new parking space, this space is already in a session"); 113 124 } 114 125 parkingSession.setStatus(SessionStatus.STARTED_VERIFIED);
Note:
See TracChangeset
for help on using the changeset viewer.