diff --git a/src/main/java/GUI/ProjectionHandler.java b/src/main/java/GUI/ProjectionHandler.java index 30e26a8..93b6568 100644 --- a/src/main/java/GUI/ProjectionHandler.java +++ b/src/main/java/GUI/ProjectionHandler.java @@ -119,18 +119,13 @@ public class ProjectionHandler extends JDialog { slotComboBox.removeAllItems(); roomComboBox.removeAllItems(); if (dayComboBox.getSelectedItem() != null) { - ArrayList slots = null; + ArrayList slots; Competition competition = (Competition) competitionComboBox.getSelectedItem(); Date date = Date.valueOf((LocalDate) dayComboBox.getSelectedItem()); - switch (projectionType) { - case ADD: + if (projectionType == ProjectionType.ADD) slots = Slot.getAvailable(competition, date); - break; - case EDIT: - break; - case REMOVE: + else slots = Slot.getAll(competition, date); - } if (slots != null) for (Slot s : slots) slotComboBox.addItem(s); @@ -146,9 +141,8 @@ public class ProjectionHandler extends JDialog { Date date = Date.valueOf((LocalDate) dayComboBox.getSelectedItem()); switch (projectionType) { case ADD: - rooms = Room.getAvailable(movie, slot, date); - break; case EDIT: + rooms = Room.getAvailable(movie, slot, date); break; case REMOVE: rooms = Room.getAll(movie, slot, date); @@ -173,6 +167,11 @@ public class ProjectionHandler extends JDialog { new Projection(date, competition, room, movie, slot); break; case EDIT: + if (projection != null) + projection.delete(); + else + (Projection.find(date, competition, room, movie, slot)).delete(); + new Projection(date, competition, room, movie, slot); break; case REMOVE: if (projection != null)