From 1fc29ae65004e7290a6cd7d1847267965437d19d Mon Sep 17 00:00:00 2001 From: Jade_VAN_BRABANDT Date: Wed, 31 May 2023 16:20:02 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20:=20Ca=20marche=20mais=20c'moche=20mais?= =?UTF-8?q?=20=C3=A7a=20marche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Stim/MainPage.xaml.cs | 52 +++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/Sources/Stim/MainPage.xaml.cs b/Sources/Stim/MainPage.xaml.cs index d6e26dc..1ac0340 100644 --- a/Sources/Stim/MainPage.xaml.cs +++ b/Sources/Stim/MainPage.xaml.cs @@ -5,6 +5,7 @@ using StimStub; using Microsoft.Maui.Storage; using MailKit.Search; using System.Linq; +using System.Collections.Generic; public partial class MainPage : ContentPage { @@ -31,18 +32,65 @@ public partial class MainPage : ContentPage string Tag1Text = Tag1.Text; string Tag2Text = Tag2.Text; ((App)App.Current).Manager.ResearchedGame.Clear(); - - var filteredGames = ((App)App.Current).Manager.GameList + IEnumerable filteredGames = ((App)App.Current).Manager.GameList; + if (GameText != null && Tag1Text != null && Tag2.Text != null) + { + filteredGames = ((App)App.Current).Manager.GameList .Where(game => game.Name.IndexOf(GameText, StringComparison.OrdinalIgnoreCase) >= 0 && game.Tags.Any(tag => tag.IndexOf(Tag1Text, StringComparison.OrdinalIgnoreCase) >= 0) && game.Tags.Any(tag => tag.IndexOf(Tag2Text, StringComparison.OrdinalIgnoreCase) >= 0) ); + } + if (GameText == null && Tag1Text !=null && Tag2Text !=null) + { + filteredGames = ((App)App.Current).Manager.GameList + .Where(game => game.Tags.Any(tag => tag.IndexOf(Tag1Text, StringComparison.OrdinalIgnoreCase) >= 0) + && + game.Tags.Any(tag => tag.IndexOf(Tag2Text, StringComparison.OrdinalIgnoreCase) >= 0) + ); + } + if (GameText != null && Tag1Text == null && Tag2Text != null) + { + filteredGames = ((App)App.Current).Manager.GameList + .Where(game => game.Name.IndexOf(GameText, StringComparison.OrdinalIgnoreCase) >= 0 + && + game.Tags.Any(tag => tag.IndexOf(Tag2Text, StringComparison.OrdinalIgnoreCase) >= 0) + ); + } + if (GameText != null && Tag1Text != null && Tag2Text == null) + { + filteredGames = ((App)App.Current).Manager.GameList + .Where(game => game.Name.IndexOf(GameText, StringComparison.OrdinalIgnoreCase) >= 0 + && + game.Tags.Any(tag => tag.IndexOf(Tag1Text, StringComparison.OrdinalIgnoreCase) >= 0) + ); + } + if (GameText == null && Tag1Text==null && Tag2Text!=null) + { + filteredGames = ((App)App.Current).Manager.GameList + .Where(game => game.Tags.Any(tag => tag.IndexOf(Tag2Text, StringComparison.OrdinalIgnoreCase) >= 0) + ); + } + if (GameText==null &&Tag1Text!=null&& Tag2Text ==null) + { + filteredGames = ((App)App.Current).Manager.GameList + .Where(game => game.Tags.Any(tag => tag.IndexOf(Tag1Text, StringComparison.OrdinalIgnoreCase) >= 0) + ); + } + if (GameText!=null&& Tag1Text == null && Tag2Text==null) + { + filteredGames = ((App)App.Current).Manager.GameList + .Where(game => game.Name.IndexOf(GameText, StringComparison.OrdinalIgnoreCase) >= 0 + ); + } foreach (var game in filteredGames) { ((App)App.Current).Manager.ResearchedGame.Add(game); } + + } }