diff --git a/src/Controllers/event.controller.ts b/src/Controllers/event.controller.ts index 3193c37..42706f3 100644 --- a/src/Controllers/event.controller.ts +++ b/src/Controllers/event.controller.ts @@ -241,7 +241,7 @@ export const deleteEvent = async (req: Request, res: Res return res.status(204).end(); } catch (e) { if (e instanceof PrismaClientKnownRequestError && e.code === "P2025") { - return res.status(404).json(generateError(`The organisation with the ID ${pid} could not be found`)); + return res.status(404).json(generateError(`The event with the ID ${pid} could not be found`)); } throw e; diff --git a/src/Controllers/participant.controller.ts b/src/Controllers/participant.controller.ts index 9eb0047..54f4b18 100644 --- a/src/Controllers/participant.controller.ts +++ b/src/Controllers/participant.controller.ts @@ -74,7 +74,7 @@ export const createParticipant = async (req: Request<{ pid: string}>, res: Respo } } -const updateParticipant = async (req: Request<{ pid: string }>, res: Response) => { +export const updateParticipant = async (req: Request<{ pid: string }>, res: Response) => { //insert TeamleaderAuth const result = updateParticipantBody.safeParse(req.body); @@ -138,3 +138,21 @@ const updateParticipant = async (req: Request<{ pid: string }>, res: Response) = throw e; } } + +export const deleteParticipant = async (req: Request<{ pid: string }>, res: Response) => { + //insert TeamleaderAuth + + const { pid } = req.params; + + try { + await prisma.participant.delete({ where: { pid } }); + + return res.status(204).end(); + } catch (e) { + if (e instanceof PrismaClientKnownRequestError && e.code === "P2025") { + return res.status(404).json(generateError(`The participant with the ID ${pid} could not be found`)); + } + + throw e; + } +} \ No newline at end of file