From dcdfe59a6ebf929edb1d1b284f96ddc02b5db96f Mon Sep 17 00:00:00 2001 From: Jade_VAN_BRABANDT Date: Mon, 5 Jun 2023 13:54:32 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20:=20Bug=20sur=20la=20mise=20=C3=A0=20jour?= =?UTF-8?q?=20apr=C3=A8s=20ajout=20d'un=20jeu=20(Merci=20Samuel=20pour=20l?= =?UTF-8?q?'aide)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Stim.Model/Game.cs | 2 +- Sources/Stim.Model/Manager.cs | 22 ++++++++++ Sources/Stim.Model/User.cs | 5 ++- Sources/Stim/AddGamePage.xaml.cs | 4 +- Sources/Stim/Create.xaml | 12 +++--- Sources/Stim/Create.xaml.cs | 72 +++++++++++++++++--------------- Sources/Stim/EntryPopup.xaml | 7 ++-- Sources/Stim/EntryPopup.xaml.cs | 5 +++ Sources/Stim/LoginPage.xaml | 41 ++++++++++++------ Sources/Stim/LoginPage.xaml.cs | 20 ++++++--- Sources/Stim/MainPage.xaml | 2 +- Sources/Stim/MainPage.xaml.cs | 22 +++------- Sources/Stim/UserInfo.xaml.cs | 5 +-- 13 files changed, 133 insertions(+), 86 deletions(-) diff --git a/Sources/Stim.Model/Game.cs b/Sources/Stim.Model/Game.cs index 93c1d04..b78cdd5 100644 --- a/Sources/Stim.Model/Game.cs +++ b/Sources/Stim.Model/Game.cs @@ -10,7 +10,7 @@ namespace Model public class Game : INotifyPropertyChanged, IEquatable { [DataMember] - public string? Name + public string Name { get => name; private set diff --git a/Sources/Stim.Model/Manager.cs b/Sources/Stim.Model/Manager.cs index 75c1608..da4e746 100644 --- a/Sources/Stim.Model/Manager.cs +++ b/Sources/Stim.Model/Manager.cs @@ -12,6 +12,12 @@ namespace Model } private IPersistance mgrpersistance; public ObservableCollection GameList { get;} + + // dégage ça + // fait une méthode qui te renvoie une liste filtrer avec les params (genre ton nom :D) + // Quand t'ajoute peut être que dasn un certains monde + // il y aura pas le pb car c'est le retour d'une collection Obs + // donc potentiellement si les astres sont alignés ça devrait la mettre à jour public ObservableCollection ResearchedGame { get; set; } public User CurrentUser { get; set; } public HashSet Users { get; set; } @@ -29,6 +35,22 @@ namespace Model } } + public IEnumerable FilterGames(string? filterName, string? filterTag1, string? filterTag2) + { + IEnumerable retList; + retList = GameList; + if (filterName != null) retList = retList + .Where(game => game.Name.IndexOf(filterName, StringComparison.OrdinalIgnoreCase) >= 0 + ); + if (filterTag1 != null) retList = retList + .Where(game => game.Tags.Any(tag => tag.IndexOf(filterTag1, StringComparison.OrdinalIgnoreCase) >= 0) + ); + if (filterTag2 != null) retList = retList + .Where(game => game.Tags.Any(tag => tag.IndexOf(filterTag2, StringComparison.OrdinalIgnoreCase) >= 0) + ); + return retList; + } + public void AddGametoGamesList(Game game) { GameList.Add(game); diff --git a/Sources/Stim.Model/User.cs b/Sources/Stim.Model/User.cs index 3fc12a7..25296b0 100644 --- a/Sources/Stim.Model/User.cs +++ b/Sources/Stim.Model/User.cs @@ -122,8 +122,9 @@ namespace Model return other != null && Username.Equals(other.Username); } public override int GetHashCode() - { - return Username.GetHashCode(); + { + if (Username!=null) return Username.GetHashCode(); + return 0; } public void AddReview(Game game, float rate, string text) diff --git a/Sources/Stim/AddGamePage.xaml.cs b/Sources/Stim/AddGamePage.xaml.cs index db7d2c8..328e8e6 100644 --- a/Sources/Stim/AddGamePage.xaml.cs +++ b/Sources/Stim/AddGamePage.xaml.cs @@ -29,8 +29,10 @@ public partial class AddGamePage : ContentPage { message = "Jeu ajouté !"; ((App)App.Current).Manager.AddGametoGamesList(new Game(NameEntry.Text, DescriptionEntry.Text, year, new List { TagEntry1.Text, TagEntry2.Text, TagEntry3.Text }, imgName, LinkEntry.Text)); - Navigation.RemovePage(this); + await this.ShowPopupAsync(new MessagePopup(message)); + await Navigation.PopModalAsync(); ((App)App.Current).Manager.SaveGames(); + } // //if (_ImgPath!=null) NameEntry.Text + ".png"; // //System.IO.File.Copy(_ImgPath, /**/, true); diff --git a/Sources/Stim/Create.xaml b/Sources/Stim/Create.xaml index a267e1b..bc60331 100644 --- a/Sources/Stim/Create.xaml +++ b/Sources/Stim/Create.xaml @@ -22,11 +22,11 @@ - - - + + + - + @@ -40,13 +40,13 @@ - +