Implement complete() (2.1.1.1)

This commit is contained in:
Tobias Eidelpes 2021-04-27 11:09:49 +02:00
parent a36f812edf
commit 2b4ee8acbf

View File

@ -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 {