Add recipe deletion functionality and enhance inventory consumption details
This commit is contained in:
@@ -345,6 +345,19 @@ export class RecipesService {
|
||||
return recipe;
|
||||
}
|
||||
|
||||
async remove(id: number) {
|
||||
const existingRecipe = await this.prisma.recipe.findUnique({
|
||||
where: { id },
|
||||
});
|
||||
|
||||
if (!existingRecipe) {
|
||||
throw new NotFoundException(`Recipe with id ${id} not found`);
|
||||
}
|
||||
|
||||
await this.prisma.recipeIngredient.deleteMany({ where: { recipeId: id } });
|
||||
await this.prisma.recipe.delete({ where: { id } });
|
||||
}
|
||||
|
||||
async create(createRecipeDto: CreateRecipeDto) {
|
||||
const recipe = await this.prisma.recipe.create({
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user