diff --git a/src/Mealz/MealBundle/Controller/MealAdminController.php b/src/Mealz/MealBundle/Controller/MealAdminController.php index eaca69968..2ee7d93de 100644 --- a/src/Mealz/MealBundle/Controller/MealAdminController.php +++ b/src/Mealz/MealBundle/Controller/MealAdminController.php @@ -304,12 +304,18 @@ private function handleEventArr(array $eventArr, Day $day): void{ private function addEvent(array $event, Day $dayEntity){ $this->logger->info('EventId: '. $event['eventId']. ', name: '. $event['eventSlug']); - $eventEntity = $this->mealAdminHelper->findEvent($event['eventId']); - $eventExistsForDayAlready = $this->mealAdminHelper->checkIfEventExistsForDay($event['eventId'], $dayEntity); - if(!$eventExistsForDayAlready){ - $this->logger->info('addEvent'); - $eventParticipationEntity = new EventParticipation($dayEntity, $eventEntity); - $dayEntity->addEvent($eventParticipationEntity); + if(!isset($event['eventId'])){ + $this->logger->info('Event wird gelöscht'); + } else{ + $eventEntity = $this->mealAdminHelper->findEvent($event['eventId']); + $eventExistsForDayAlready = $this->mealAdminHelper->checkIfEventExistsForDay($event['eventId'], $dayEntity); + if(!$eventExistsForDayAlready){ + $this->logger->info('addEvent'); + $eventParticipationEntity = new EventParticipation($dayEntity, $eventEntity); + $dayEntity->addEvent($eventParticipationEntity); + } else{ + throw new Exception('Meal exists for day already'); + } } } diff --git a/src/Resources/src/components/menu/MenuDay.vue b/src/Resources/src/components/menu/MenuDay.vue index 435945662..96e65e93e 100644 --- a/src/Resources/src/components/menu/MenuDay.vue +++ b/src/Resources/src/components/menu/MenuDay.vue @@ -1,11 +1,9 @@