From ffbe559f329771f77e99496e3bb314e003bb3bb8 Mon Sep 17 00:00:00 2001 From: chloe Date: Thu, 19 Mar 2026 20:45:46 +0000 Subject: [PATCH] added delete button --- .../Controllers/RecipeController.cs | 19 +++ Seasoned.Frontend/app/pages/gallery.vue | 109 +++++++++++++++--- 2 files changed, 110 insertions(+), 18 deletions(-) diff --git a/Seasoned.Backend/Controllers/RecipeController.cs b/Seasoned.Backend/Controllers/RecipeController.cs index 843efb3..d59782c 100644 --- a/Seasoned.Backend/Controllers/RecipeController.cs +++ b/Seasoned.Backend/Controllers/RecipeController.cs @@ -155,4 +155,23 @@ public class RecipeController : ControllerBase return Ok(results); } + + [HttpDelete("{id}")] + public async Task DeleteRecipe(int id) + { + var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); + + var recipe = await _context.Recipes + .FirstOrDefaultAsync(r => r.Id == id && r.UserId == userId); + + if (recipe == null) + { + return NotFound("Recipe not found or you don't have permission to delete it."); + } + + _context.Recipes.Remove(recipe); + await _context.SaveChangesAsync(); + + return Ok(new { message = "Recipe deleted from your archives." }); + } } \ No newline at end of file diff --git a/Seasoned.Frontend/app/pages/gallery.vue b/Seasoned.Frontend/app/pages/gallery.vue index 41f1688..471c990 100644 --- a/Seasoned.Frontend/app/pages/gallery.vue +++ b/Seasoned.Frontend/app/pages/gallery.vue @@ -70,24 +70,28 @@