summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java
index ac6470e..4653663 100644
--- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java
+++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java
@@ -149,25 +149,28 @@ public class RegistrationWindowController {
LOG.debug("Create Button clicked");
Set<Registration> registrations = new HashSet<>();
-
- for (Employee employee : chosenEmployees) {
- registrations.add(
- Registration.builder()
- .id(chosenVehicle.id())
- .employee(employee)
- .start(
- LocalDateTime.of(
- LocalDate.now(),
- LocalTime.of(cbStart.getValue(), 0))
- .toInstant(OffsetDateTime.now().getOffset()))
- .end(
- LocalDateTime.of(
- LocalDate.now(),
- LocalTime.of(cbEnd.getValue(), 0))
- .toInstant(OffsetDateTime.now().getOffset()))
- .build());
- }
try {
+ if (chosenVehicle == null) {
+ throw new InvalidVehicleException("no Vehicle");
+ }
+ for (Employee employee : chosenEmployees) {
+ registrations.add(
+ Registration.builder()
+ .id(chosenVehicle.id())
+ .employee(employee)
+ .start(
+ LocalDateTime.of(
+ LocalDate.now(),
+ LocalTime.of(cbStart.getValue(), 0))
+ .toInstant(OffsetDateTime.now().getOffset()))
+ .end(
+ LocalDateTime.of(
+ LocalDate.now(),
+ LocalTime.of(cbEnd.getValue(), 0))
+ .toInstant(OffsetDateTime.now().getOffset()))
+ .build());
+ }
+
registrationService.add(chosenVehicle.id(), registrations);
chosenEmployees.clear();
((Stage) lVehicles.getScene().getWindow()).close();