Implement complete() (2.1.1.1)
This commit is contained in:
parent
a36f812edf
commit
2b4ee8acbf
@ -117,11 +117,27 @@ public class TripService implements ITripService {
|
||||
entityManager.persist(newMatch);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void complete(Long tripId, TripInfoDTO tripInfoDTO) throws EntityNotFoundException {
|
||||
|
||||
ITrip trip = getTrip(tripId);
|
||||
ITripInfo tripInfo = modelFactory.createTripInfo();
|
||||
// Set tripInfo data
|
||||
tripInfo.setCompleted(tripInfoDTO.getCompleted());
|
||||
tripInfo.setDistance(tripInfoDTO.getDistance());
|
||||
// Set total
|
||||
IMoney money = modelFactory.createMoney();
|
||||
money.setCurrency(tripInfoDTO.getFare().getCurrency());
|
||||
money.setValue(tripInfoDTO.getFare().getValue());
|
||||
tripInfo.setTotal(money);
|
||||
// Set trip and tripInfo
|
||||
tripInfo.setTrip(trip);
|
||||
trip.setTripInfo(tripInfo);
|
||||
entityManager.persist(tripInfo);
|
||||
entityManager.merge(trip);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void cancel(Long tripId) throws EntityNotFoundException {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user