From 5dfd426c3e8dd956b2ae111b2b4dc30e067f3728 Mon Sep 17 00:00:00 2001 From: HMatheo Date: Sat, 20 May 2023 13:44:17 +0200 Subject: [PATCH 1/3] Fixed data overwriting problem. --- MangaMap/App.xaml.cs | 2 +- MangaMap/Stub/DataContract.cs | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/MangaMap/App.xaml.cs b/MangaMap/App.xaml.cs index f247bfb..f852825 100644 --- a/MangaMap/App.xaml.cs +++ b/MangaMap/App.xaml.cs @@ -18,7 +18,7 @@ public partial class App : Application MyManager.Admins.Add(MyAdmin); MainPage = new AppShell(); - MyManager.Persistance = new DataContract(); + //MyManager.Persistance = new DataContract(); MyManager.sauvegarder(); } diff --git a/MangaMap/Stub/DataContract.cs b/MangaMap/Stub/DataContract.cs index f2d0f3e..837c007 100644 --- a/MangaMap/Stub/DataContract.cs +++ b/MangaMap/Stub/DataContract.cs @@ -39,8 +39,8 @@ namespace MangaMap.Stub public void sauvegarder(List o, List u) { var serializer = new DataContractSerializer(typeof(DataToPersist)); - DataToPersist data; + if (File.Exists(Path.Combine(FilePath, FileName))) { using (Stream s = File.OpenRead(Path.Combine(FilePath, FileName))) @@ -53,19 +53,22 @@ namespace MangaMap.Stub data = new DataToPersist(); } - // Vérifier si un utilisateur avec le même nom d'utilisateur existe déjà - var existingUser = data.Utilisateurs.FirstOrDefault(user => user.Pseudo == u.Last().Pseudo); - if (existingUser != null) - { - // Mettre à jour l'utilisateur existant - existingUser.MotDePasse = u.Last().MotDePasse; - existingUser.Email = u.Last().Email; - - } - else + // Parcourir les nouveaux utilisateurs + foreach (var newUser in u) { - // Ajouter le nouvel utilisateur à la liste existante - data.Utilisateurs.Add(u.Last()); + // Vérifier si un utilisateur avec le même nom d'utilisateur existe déjà + var existingUser = data.Utilisateurs.FirstOrDefault(user => user.Pseudo == newUser.Pseudo); + if (existingUser != null) + { + // Mettre à jour les informations de l'utilisateur existant + existingUser.MotDePasse = newUser.MotDePasse; + existingUser.Email = newUser.Email; + } + else + { + // Ajouter le nouvel utilisateur à la liste existante + data.Utilisateurs.Add(newUser); + } } var settings = new XmlWriterSettings() { Indent = true }; @@ -77,6 +80,7 @@ namespace MangaMap.Stub } } } + } } \ No newline at end of file From eb705a874f0e45b9a31f2893663244f700d231ff Mon Sep 17 00:00:00 2001 From: Matheo HERSAN Date: Wed, 31 May 2023 15:59:15 +0200 Subject: [PATCH 2/3] Added logos and navigation --- MangaMap/AppShell.xaml | 2 +- MangaMap/CustomHeader.xaml | 19 ++++++++++--------- MangaMap/Resources/Images/listbutton.png | Bin 0 -> 494 bytes 3 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 MangaMap/Resources/Images/listbutton.png diff --git a/MangaMap/AppShell.xaml b/MangaMap/AppShell.xaml index 127b9d3..b79ea35 100644 --- a/MangaMap/AppShell.xaml +++ b/MangaMap/AppShell.xaml @@ -7,7 +7,7 @@ xmlns:Views="clr-namespace:MangaMap.Views" Shell.FlyoutBehavior="Disabled" Shell.NavBarIsVisible="False" - Shell.TabBarIsVisible="True"> + Shell.TabBarIsVisible="False"> diff --git a/MangaMap/CustomHeader.xaml b/MangaMap/CustomHeader.xaml index 46f2ea5..d1eb227 100644 --- a/MangaMap/CustomHeader.xaml +++ b/MangaMap/CustomHeader.xaml @@ -3,26 +3,26 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MangaMap.NewContent1" Background="{StaticResource Primary}"> - + -