From a47fc413fe0237adc8277097e602ea96ac868f32 Mon Sep 17 00:00:00 2001 From: thchazot1 Date: Wed, 25 May 2022 17:03:20 +0200 Subject: [PATCH] Nv fonction de recherche maintenant dans le manager --- Business/Manager.cs | 35 ++++++++++++++++++++++++++++++++++- WpfApp1/MainWindow.xaml.cs | 27 +++------------------------ 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/Business/Manager.cs b/Business/Manager.cs index 3e40bf5..b123c42 100644 --- a/Business/Manager.cs +++ b/Business/Manager.cs @@ -81,6 +81,39 @@ namespace Business return true; } - + public List rechercherRequins(ReadOnlyCollection lRech, Nullable zone, string motif) + { + List nvReq = new List(); + int test = 0; + if (!string.IsNullOrWhiteSpace(motif)) + { + foreach (Requin req in lRech) + { + if (zone == null) + { + if (req.Nom.Contains(motif) || req.NomSci.Contains(motif)) + { + nvReq.Add(req); + } + } + else + { + foreach (Zone z in req.Repartition) + { + if ((req.Nom.Contains(motif) || req.NomSci.Contains(motif)) && zone == z) + { + test++; + } + } + if (test > 0) + { + nvReq.Add(req); + } + } + test = 0; + } + } + return nvReq; + } } } \ No newline at end of file diff --git a/WpfApp1/MainWindow.xaml.cs b/WpfApp1/MainWindow.xaml.cs index b8cb809..ea47dc0 100644 --- a/WpfApp1/MainWindow.xaml.cs +++ b/WpfApp1/MainWindow.xaml.cs @@ -167,33 +167,12 @@ namespace WpfApp1 viderListBox(); List nvReq = new List(); string rech = Rechercher.Text; - int test = 0; if (!string.IsNullOrWhiteSpace(rech)) { - foreach (Requin req in Mgr.Requins) + nvReq = Mgr.rechercherRequins(Mgr.Requins, zonePage, rech); + foreach(Requin req in nvReq) { - if (zonePage == null) - { - if (req.Nom.Contains(rech) || req.NomSci.Contains(rech)) - { - laListe.Items.Add((new UserControlRequin { requin = req })); - } - } - else - { - foreach (Zone z in req.Repartition) - { - if ((req.Nom.Contains(rech) || req.NomSci.Contains(rech)) && zonePage==z) - { - test++; - } - } - if (test > 0) - { - laListe.Items.Add((new UserControlRequin { requin = req })); - } - } - test = 0; + laListe.Items.Add(new UserControlRequin { requin = req }); } } else