feat: implement inventory and pantry management views with CRUD functionality and user-friendly interfaces
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
ParseIntPipe,
|
||||
@@ -55,4 +56,9 @@ findConsumptionHistory(@Param('id', ParseIntPipe) id: number) {
|
||||
) {
|
||||
return this.inventoryService.update(id, body);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.inventoryService.remove(id);
|
||||
}
|
||||
}
|
||||
@@ -239,4 +239,12 @@ export class InventoryService {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async remove(id: number) {
|
||||
const existing = await this.prisma.inventoryItem.findUnique({ where: { id } });
|
||||
if (!existing) {
|
||||
throw new NotFoundException(`Inventory item with id ${id} not found`);
|
||||
}
|
||||
return this.prisma.inventoryItem.delete({ where: { id } });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user