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 @@ - +