Implemented the text element filter
This commit is contained in:
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:
|
||||
|
||||
Reference in new issue
Block a user