From 6de8fcca19eff9566517ca0f1556c412a2032816 Mon Sep 17 00:00:00 2001 From: Jade_VAN_BRABANDT Date: Wed, 24 May 2023 14:46:48 +0200 Subject: [PATCH] Feat : ajout lien --- Sources/AppConsole/Program.cs | 6 +- Sources/Persistance/Persistance.cs | 2 +- Sources/Stim.Model/Game.cs | 22 ++- Sources/Stim.Model/Manager.cs | 9 + Sources/Stim/AddGamePage.xaml.cs | 2 +- Sources/Stim/DetailledPage.xaml | 2 +- Sources/Stim/DetailledPage.xaml.cs | 1 + Sources/Stub/Stub.cs | 8 +- Sources/TestProject1/TestGame.cs | 62 +++--- Sources/TestProject1/TestManager.cs | 2 +- Sources/TestProject1/TestUser.cs | 4 +- Sources/XML/games.xml | 288 ++++++++++++++-------------- 12 files changed, 224 insertions(+), 184 deletions(-) diff --git a/Sources/AppConsole/Program.cs b/Sources/AppConsole/Program.cs index 17fa1ff..4d4b74b 100644 --- a/Sources/AppConsole/Program.cs +++ b/Sources/AppConsole/Program.cs @@ -1,5 +1,9 @@ using Model; +using StimPersistance; using StimStub; using System.Collections.ObjectModel; -Console.WriteLine("Faut une ligne pour build"); \ No newline at end of file +Console.WriteLine("Faut une ligne pour build"); +Manager Mgr = new Manager(new Stub()); +Mgr._persistance = new Persistance(); +Mgr.SaveGames(); \ No newline at end of file diff --git a/Sources/Persistance/Persistance.cs b/Sources/Persistance/Persistance.cs index 963f4c9..6ce5867 100644 --- a/Sources/Persistance/Persistance.cs +++ b/Sources/Persistance/Persistance.cs @@ -11,7 +11,7 @@ namespace StimPersistance { public Persistance() { - Directory.SetCurrentDirectory("C:\\Users\\Jade\\source\\repos\\Projet_IHM\\Sources\\XML"); + Directory.SetCurrentDirectory("C:\\Users\\axvanbraba\\source\\repos\\Projet_IHM\\Sources\\XML"); } public void SaveGame(ObservableCollection games) diff --git a/Sources/Stim.Model/Game.cs b/Sources/Stim.Model/Game.cs index bc9e9c9..ca8fe42 100644 --- a/Sources/Stim.Model/Game.cs +++ b/Sources/Stim.Model/Game.cs @@ -74,18 +74,30 @@ namespace Model [DataMember] public float Average { get; private set; } + [DataMember] + public string Lien { + get { return lien; } + private set + { + if (!string.IsNullOrWhiteSpace(value)) lien = value; + else lien = "Default"; + } + } + private string lien; + public Game() { Name = "Default"; Description = "Default"; Cover = "Default"; + Lien = "Default"; Year = 2023; tags = new ObservableCollection(); Reviews = new List(); Average = 0; } - public Game(string name, string description, int year, List c_tags, string cover) + public Game(string name, string description, int year, List c_tags, string cover, string lien) { if (name is null) Name = "Default"; else Name= name; @@ -94,10 +106,10 @@ namespace Model Year = year; if (c_tags != null) tags = new ObservableCollection(c_tags); else tags = new ObservableCollection(); - if (cover is null) - Cover = "Default"; - else - Cover = cover; + if (cover is null) Cover = "Default"; + else Cover = cover; + if (lien is null) Lien = "Default"; + else Lien = lien; Reviews = new List(); Average = 0; } diff --git a/Sources/Stim.Model/Manager.cs b/Sources/Stim.Model/Manager.cs index 13388c6..cbb00ea 100644 --- a/Sources/Stim.Model/Manager.cs +++ b/Sources/Stim.Model/Manager.cs @@ -24,5 +24,14 @@ namespace Model GameList.Remove(game); _persistance.SaveGame(GameList); } + + /*public void LoadGames() + { + _persistance.LoadGame(); + }*/ + public void SaveGames() + { + _persistance.SaveGame(GameList); + } } } diff --git a/Sources/Stim/AddGamePage.xaml.cs b/Sources/Stim/AddGamePage.xaml.cs index 63170f1..a5c0419 100644 --- a/Sources/Stim/AddGamePage.xaml.cs +++ b/Sources/Stim/AddGamePage.xaml.cs @@ -17,6 +17,6 @@ public partial class AddGamePage : ContentPage string tag1 = TagEntry1.Text; string tag2 = TagEntry2.Text; string tag3 = TagEntry3.Text; - Manager.AddGametoGamesList(new Game(NameEntry.Text, DescriptionEntry.Text, int.Parse(YearEntry.Text), new List { tag1, tag2, tag3 }, "null")); + Manager.AddGametoGamesList(new Game(NameEntry.Text, DescriptionEntry.Text, int.Parse(YearEntry.Text), new List { tag1, tag2, tag3 }, "null", "www.link.com")); } } \ No newline at end of file diff --git a/Sources/Stim/DetailledPage.xaml b/Sources/Stim/DetailledPage.xaml index 1182fc5..1a58667 100644 --- a/Sources/Stim/DetailledPage.xaml +++ b/Sources/Stim/DetailledPage.xaml @@ -61,7 +61,7 @@ -