diff --git a/FoodsharingSiegen.Server/Data/Service/ProspectService.cs b/FoodsharingSiegen.Server/Data/Service/ProspectService.cs index 910594f..48cea9d 100644 --- a/FoodsharingSiegen.Server/Data/Service/ProspectService.cs +++ b/FoodsharingSiegen.Server/Data/Service/ProspectService.cs @@ -103,11 +103,14 @@ namespace FoodsharingSiegen.Server.Data.Service /// Gets the users (a. beging, 01.04.2022) /// /// A task containing an operation result of list prospect - public async Task>> GetProspectsAsync() + public async Task>> 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>(prospects); } catch (Exception e)