| @@ 106-120 (lines=15) @@ | ||
| 103 | * ) |
|
| 104 | * @param string $eventId event id |
|
| 105 | */ |
|
| 106 | public function viewAction(string $eventId): Response |
|
| 107 | { |
|
| 108 | /** @var EventRepository $eventRepository */ |
|
| 109 | $eventRepository = $this->get('rockparade.event_repository'); |
|
| 110 | $event = $eventRepository->findOneById($eventId); |
|
| 111 | ||
| 112 | if ($event) { |
|
| 113 | $response = new ApiResponse($event, Response::HTTP_OK); |
|
| 114 | } else { |
|
| 115 | $eventService = $this->get('rockparade.event'); |
|
| 116 | $response = $eventService->createEventNotFoundErrorResult($eventId); |
|
| 117 | } |
|
| 118 | ||
| 119 | return $this->respond($response); |
|
| 120 | } |
|
| 121 | ||
| 122 | /** |
|
| 123 | * Create new event |
|
| @@ 218-235 (lines=18) @@ | ||
| 215 | * ) |
|
| 216 | * @param string $eventId event id |
|
| 217 | */ |
|
| 218 | public function deleteEvent(string $eventId): Response |
|
| 219 | { |
|
| 220 | /** @var EventRepository $eventRepository */ |
|
| 221 | $eventRepository = $this->get('rockparade.event_repository'); |
|
| 222 | $event = $eventRepository->findOneById($eventId); |
|
| 223 | ||
| 224 | if ($event) { |
|
| 225 | $eventRepository->remove($event); |
|
| 226 | $eventRepository->flush(); |
|
| 227 | ||
| 228 | $response = new EmptyApiResponse(Response::HTTP_NO_CONTENT); |
|
| 229 | } else { |
|
| 230 | $eventService = $this->get('rockparade.event'); |
|
| 231 | $response = $eventService->createEventNotFoundErrorResult($eventId); |
|
| 232 | } |
|
| 233 | ||
| 234 | return $this->respond($response); |
|
| 235 | } |
|
| 236 | ||
| 237 | /** |
|
| 238 | * Add image to event |
|
| @@ 69-81 (lines=13) @@ | ||
| 66 | * ) |
|
| 67 | * @param string $bandName band name |
|
| 68 | */ |
|
| 69 | public function viewAction(string $bandName): Response |
|
| 70 | { |
|
| 71 | $bandRepository = $this->get('rockparade.band_repository'); |
|
| 72 | $band = $bandRepository->findOneByName($bandName); |
|
| 73 | ||
| 74 | if ($band) { |
|
| 75 | $response = new ApiResponse($band, Response::HTTP_OK); |
|
| 76 | } else { |
|
| 77 | $response = $this->createBandNotFoundErrorResult($bandName); |
|
| 78 | } |
|
| 79 | ||
| 80 | return $this->respond($response); |
|
| 81 | } |
|
| 82 | ||
| 83 | /** |
|
| 84 | * Create new band |
|
| @@ 184-196 (lines=13) @@ | ||
| 181 | * } |
|
| 182 | * ) |
|
| 183 | */ |
|
| 184 | public function listMembersAction(string $bandName): Response |
|
| 185 | { |
|
| 186 | $bandRepository = $this->get('rockparade.band_repository'); |
|
| 187 | $band = $bandRepository->findOneByName($bandName); |
|
| 188 | ||
| 189 | if (!$band) { |
|
| 190 | $response = $this->createBandNotFoundErrorResult($bandName); |
|
| 191 | } else { |
|
| 192 | $response = new ApiResponse($band->getMembers(), Response::HTTP_OK); |
|
| 193 | } |
|
| 194 | ||
| 195 | return $this->respond($response); |
|
| 196 | } |
|
| 197 | ||
| 198 | /** |
|
| 199 | * Add member to band |
|