From de7605578a2273e3472bf4215543f8c5e01b12ab Mon Sep 17 00:00:00 2001 From: Andre Beging Date: Tue, 7 Feb 2023 22:19:41 +0100 Subject: [PATCH] =?UTF-8?q?Filtern=20der=20Prospects=20erm=C3=B6glichen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FoodsharingSiegen.Server/Data/Service/ProspectService.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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)