* Extended functionalities
* Added different UIs
This commit is contained in:
@@ -16,7 +16,7 @@ public class RecipeService : IRecipeService
|
||||
public RecipeService(AppDbContext db) => _db = db;
|
||||
|
||||
public async Task<IReadOnlyList<RecipeListItemDto>> GetRecipesAsync(
|
||||
int? category, string? search, CancellationToken ct = default)
|
||||
int? category, string? search, string? ingredient, CancellationToken ct = default)
|
||||
{
|
||||
var query = _db.Recipes.AsNoTracking().Where(r => r.IsActive);
|
||||
|
||||
@@ -31,6 +31,13 @@ public class RecipeService : IRecipeService
|
||||
query = query.Where(r => EF.Functions.ILike(r.Name, $"%{term}%"));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(ingredient))
|
||||
{
|
||||
var ingredientTerm = ingredient.Trim();
|
||||
query = query.Where(r =>
|
||||
r.Ingredients.Any(i => EF.Functions.ILike(i.Name, $"%{ingredientTerm}%")));
|
||||
}
|
||||
|
||||
return await query
|
||||
.OrderBy(r => r.Name)
|
||||
.Select(r => new RecipeListItemDto
|
||||
@@ -69,6 +76,7 @@ public class RecipeService : IRecipeService
|
||||
AmountGrams = i.AmountGrams,
|
||||
Unit = i.Unit,
|
||||
SortOrder = i.SortOrder,
|
||||
CatalogItemId = i.CatalogItemId,
|
||||
})
|
||||
.ToList(),
|
||||
Steps = r.Steps
|
||||
|
||||
Reference in New Issue
Block a user