diff --git a/src/devices/devices.service.ts b/src/devices/devices.service.ts index feb01f1..846971b 100644 --- a/src/devices/devices.service.ts +++ b/src/devices/devices.service.ts @@ -178,6 +178,13 @@ export class DevicesService { */ async remove(actor: ActorContext, id: number) { const current = await this.findRemovableDevice(actor, id); + const relatedTaskCount = await this.prisma.taskItem.count({ + where: { deviceId: current.id }, + }); + + if (relatedTaskCount > 0) { + throw new ConflictException(MESSAGES.DEVICE.DELETE_CONFLICT); + } try { return await this.prisma.device.delete({