From 1078d4a5ad9751003c0a69b14d856316011488c7 Mon Sep 17 00:00:00 2001 From: "remi.lavergne" Date: Wed, 31 May 2023 11:59:48 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Ajout=20connectedUser.=20Syst=C3=A8me=20de?= =?UTF-8?q?=20connexion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GameAtlas/GameAtlas/AppShell.xaml | 5 ++++ GameAtlas/GameAtlas/Models/Manager.cs | 12 ++++++++++ .../GameAtlas/Views/PageConnexion.xaml.cs | 24 +++++++++++++++++++ GameAtlas/GameAtlas/Views/PageJeu.xaml.cs | 5 +++- GameAtlas/GameAtlas/Views/PageProfil.xaml | 4 ++-- 5 files changed, 47 insertions(+), 3 deletions(-) diff --git a/GameAtlas/GameAtlas/AppShell.xaml b/GameAtlas/GameAtlas/AppShell.xaml index b2ff4c2..381d174 100644 --- a/GameAtlas/GameAtlas/AppShell.xaml +++ b/GameAtlas/GameAtlas/AppShell.xaml @@ -35,6 +35,11 @@ + diff --git a/GameAtlas/GameAtlas/Models/Manager.cs b/GameAtlas/GameAtlas/Models/Manager.cs index 235409c..5f4bf7d 100644 --- a/GameAtlas/GameAtlas/Models/Manager.cs +++ b/GameAtlas/GameAtlas/Models/Manager.cs @@ -12,8 +12,20 @@ namespace GameAtlas.Models public List ListJeux { get; private set; } public List Admins { get; private set; } public List Utilisateurs { get; private set; } + public IPersistanceManager Persistance { get; set; } + public Utilisateur ConnectedUser + { + get => connectedUser; + set + { + connectedUser = value; + //OnPropertyChanged(); + } + } + private Utilisateur connectedUser; + public Manager(IPersistanceManager persistance) { diff --git a/GameAtlas/GameAtlas/Views/PageConnexion.xaml.cs b/GameAtlas/GameAtlas/Views/PageConnexion.xaml.cs index 5d13115..69d0fb6 100644 --- a/GameAtlas/GameAtlas/Views/PageConnexion.xaml.cs +++ b/GameAtlas/GameAtlas/Views/PageConnexion.xaml.cs @@ -1,8 +1,13 @@ namespace GameAtlas.Views; + +using GameAtlas.Models; +using System.Diagnostics; using System.Text.RegularExpressions; public partial class PageConnexion : ContentPage { + + public Manager ConnexionManager => (App.Current as App).MyManager; public PageConnexion() { InitializeComponent(); @@ -21,7 +26,26 @@ public partial class PageConnexion : ContentPage return; } + Verification(username, password); await Navigation.PushAsync(new PageAcceuil()); } + + public bool Verification(string username, string password) + { + foreach (Utilisateur user in ConnexionManager.Utilisateurs) + { + if (user.Pseudo == username) + { + Debug.WriteLine($"Pseudo \"{user.Pseudo}\" vérifié et valide"); + if (user.Mdp == password) + { + Debug.WriteLine("Mot de Passe verifié et valide"); + ConnexionManager.ConnectedUser = user; + return true; + } + } + } + return false; + } } \ No newline at end of file diff --git a/GameAtlas/GameAtlas/Views/PageJeu.xaml.cs b/GameAtlas/GameAtlas/Views/PageJeu.xaml.cs index 3127271..acef4df 100644 --- a/GameAtlas/GameAtlas/Views/PageJeu.xaml.cs +++ b/GameAtlas/GameAtlas/Views/PageJeu.xaml.cs @@ -33,7 +33,10 @@ public partial class PageJeu : ContentPage string action = await DisplayActionSheet("Choix de la liste:", "Annuler", null, "Mes Favoris", "Jeux Possédés", "Ma Wishlist"); Debug.WriteLine("Popup Action: " + action); - //if (action == "") + if (action == "Mes Favoris") + { + JeuManager.ConnectedUser.ListeFavoris.Add(JeuModel); + } } diff --git a/GameAtlas/GameAtlas/Views/PageProfil.xaml b/GameAtlas/GameAtlas/Views/PageProfil.xaml index 8a4e2b6..738fc73 100644 --- a/GameAtlas/GameAtlas/Views/PageProfil.xaml +++ b/GameAtlas/GameAtlas/Views/PageProfil.xaml @@ -32,7 +32,7 @@ - @@ -66,7 +66,7 @@ diff --git a/GameAtlas/GameAtlas/Views/PageConnexion.xaml.cs b/GameAtlas/GameAtlas/Views/PageConnexion.xaml.cs index 69d0fb6..1fae4f0 100644 --- a/GameAtlas/GameAtlas/Views/PageConnexion.xaml.cs +++ b/GameAtlas/GameAtlas/Views/PageConnexion.xaml.cs @@ -6,6 +6,7 @@ using System.Text.RegularExpressions; public partial class PageConnexion : ContentPage { + public int compteur { get; set; } = 0; public Manager ConnexionManager => (App.Current as App).MyManager; public PageConnexion() @@ -31,6 +32,27 @@ public partial class PageConnexion : ContentPage } + private async void OnInscrire_Tapped(object sender, EventArgs e) + { + await Navigation.PushAsync(new PageInscription()); + } + + private async void OnMotDePasseOublie_Tapped(object sender, EventArgs e) + { + await DisplayAlert("Oh non !", "Le mot de passe va te revenir à force", "Concentration"); + await DisplayAlert("Oh non !", "Encore un petit effort !", "Concentration"); + + bool reponse = await DisplayAlert("Alors ?", "Tu l'as retrouvé ce mot de passe ?", "Oui", "Non"); + if (!reponse) + { + await DisplayAlert("...", "Désolé on peut rien pour toi. La prochaine fois utilise un papier comme tout le monde.", "RIP"); + } + else + { + await DisplayAlert("...", "C'est bien, la prochaine fois tu le notera.", "Ok"); + } + } + public bool Verification(string username, string password) { foreach (Utilisateur user in ConnexionManager.Utilisateurs) @@ -46,6 +68,8 @@ public partial class PageConnexion : ContentPage } } } + Debug.WriteLine("La connection a echouée (pseudo ou mot de passe invalide)"); + ConnexionManager.ConnectedUser = null; return false; } } \ No newline at end of file