Saving recipe update

This commit is contained in:
2026-03-06 18:01:47 +00:00
parent 3501f36f5f
commit 6a35589b93
3 changed files with 70 additions and 22 deletions

View File

@@ -61,4 +61,18 @@ public class RecipeController : ControllerBase
return Ok(new { message = "Recipe saved to your collection!" });
}
[Authorize]
[HttpGet("my-collection")]
public async Task<ActionResult<IEnumerable<Recipe>>> GetMyRecipes()
{
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
var myRecipes = await _context.Recipes
.Where(r => r.UserId == userId)
.OrderByDescending(r => r.CreatedAt)
.ToListAsync();
return Ok(myRecipes);
}
}