Filtern der Prospects ermöglichen
This commit is contained in:
@@ -103,11 +103,14 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
/// Gets the users (a. beging, 01.04.2022)
|
||||
/// </summary>
|
||||
/// <returns>A task containing an operation result of list prospect</returns>
|
||||
public async Task<OperationResult<List<Prospect>>> GetProspectsAsync()
|
||||
public async Task<OperationResult<List<Prospect>>> GetProspectsAsync(InteractionType? filterType = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var prospects = await Context.Prospects!.AsNoTracking().Include(x => x.Interactions.OrderBy(i => i.Date)).ThenInclude(x => x.User).OrderBy(x => x.Name).ToListAsync();
|
||||
var prospectsQuery = Context.Prospects!.AsNoTracking().Include(x => x.Interactions.OrderBy(i => i.Date)).ThenInclude(x => x.User).OrderBy(x => x.Name).AsQueryable();
|
||||
if(filterType != null) prospectsQuery = prospectsQuery.Where(x => x.Interactions.Any(i => i.Type == filterType));
|
||||
var prospects = await prospectsQuery.ToListAsync();
|
||||
|
||||
return new OperationResult<List<Prospect>>(prospects);
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
Reference in New Issue
Block a user