Implemented the text element filter

This commit is contained in:
tsommer committed 2022-07-21 21:14:32 +02:00
1 parent e08c94177a
commit e762cfe21e
3 files changed
+15 -8

No files matched your search

@@ -8,10 +8,14 @@ namespace Processor;
public static class TextElementProcessor
{
// Load all text elements for one particular section:
public static async Task<List<TextElement>> GetTextElements(Section section)
public static async Task<List<TextElement>> GetTextElements(Section section, string filterTerm)
{
await using var db = ProcessorMeta.ServiceProvider.GetRequiredService<DataContext>();
return await db.TextElements.Where(n => n.Section == section).OrderBy(n => n.Name).ThenBy(n => n.Id).ToListAsync();
if(string.IsNullOrWhiteSpace(filterTerm))
return await db.TextElements.Where(n => n.Section == section).OrderBy(n => n.Name).ThenBy(n => n.Id).ToListAsync();
else
return await db.TextElements.Where(n => n.Section == section && n.Name.Contains(filterTerm)).OrderBy(n => n.Name).ThenBy(n => n.Id).ToListAsync();
}
// Load one text element by id: