* Extended functionalities
* Added different UIs
This commit is contained in:
@@ -14,12 +14,16 @@ public class RecipesController : ControllerBase
|
||||
|
||||
public RecipesController(IRecipeService recipeService) => _recipeService = recipeService;
|
||||
|
||||
/// <summary>Lists active recipes, optionally filtered by category and/or name search.</summary>
|
||||
/// <summary>
|
||||
/// Lists active recipes, optionally filtered by category, recipe-name search,
|
||||
/// and/or an ingredient name (returns recipes that contain that ingredient).
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(IReadOnlyList<RecipeListItemDto>), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> GetRecipes(
|
||||
[FromQuery] int? category,
|
||||
[FromQuery] string? search,
|
||||
[FromQuery] string? ingredient,
|
||||
CancellationToken ct)
|
||||
{
|
||||
if (category is < 0 or > 3)
|
||||
@@ -27,7 +31,7 @@ public class RecipesController : ControllerBase
|
||||
return BadRequest(new { error = "category must be between 0 and 3." });
|
||||
}
|
||||
|
||||
var recipes = await _recipeService.GetRecipesAsync(category, search, ct);
|
||||
var recipes = await _recipeService.GetRecipesAsync(category, search, ingredient, ct);
|
||||
return Ok(recipes);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user