From 0f00183fdc1941f3a3e77cc692be26597252593b Mon Sep 17 00:00:00 2001 From: hulivet1 Date: Fri, 6 Jan 2023 11:34:57 +0100 Subject: [PATCH] =?UTF-8?q?R=C3=A9paration=20de=20PersAPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Data/PersAPI.cs | 13 +++++++------ Sources/Data/PersStub.cs | 4 ++-- Sources/IHM/IHM.csproj | 2 +- Sources/IHM/Mobile/Dashboard.xaml.cs | 7 ++++--- Sources/IHM/Mobile/ForgetPassword.xaml.cs | 5 +++-- Sources/IHM/Mobile/Inscription.xaml.cs | 4 ++-- Sources/IHM/Mobile/MainPage.xaml.cs | 6 +++--- Sources/IHM/Platforms/Android/MainApplication.cs | 3 ++- Sources/Modele/IPersistanceManager.cs | 4 ++-- 9 files changed, 26 insertions(+), 22 deletions(-) diff --git a/Sources/Data/PersAPI.cs b/Sources/Data/PersAPI.cs index e050a2e..9632e64 100644 --- a/Sources/Data/PersAPI.cs +++ b/Sources/Data/PersAPI.cs @@ -13,9 +13,10 @@ namespace Data // /!\ et ne doit en aucun cas manipuler la mémoire ! //actions sur les inscrits - public bool AjouterInscrit(Inscrit inscrit) + public async Task AjouterInscrit(Inscrit inscrit) { - return ClientAPI.PostAddInscritAsync(inscrit.Nom, inscrit.Prenom, inscrit.Mail, inscrit.Mdp).GetAwaiter().GetResult(); + return await ClientAPI.PostAddInscritAsync(inscrit.Nom, inscrit.Prenom, inscrit.Mail, inscrit.Mdp); + } public bool SupprimerInscrit(Inscrit inscrit) { @@ -34,14 +35,14 @@ namespace Data } return inscrits.FirstOrDefault(); } - public bool EmailDisponible(string mail) + public async Task EmailDisponible(string mail) { - List inscrits = ClientAPI.GetInscritAsync(mail).GetAwaiter().GetResult(); + List inscrits = await ClientAPI.GetInscritAsync(mail); if (inscrits.Count >= 1) { - return false; + return true; } - return true; + return false; } diff --git a/Sources/Data/PersStub.cs b/Sources/Data/PersStub.cs index fb5c37c..c91bb20 100644 --- a/Sources/Data/PersStub.cs +++ b/Sources/Data/PersStub.cs @@ -171,7 +171,7 @@ namespace Data throw new NotImplementedException(); } - public bool AjouterInscrit(Inscrit inscrit) + public Task AjouterInscrit(Inscrit inscrit) { throw new NotImplementedException(); } @@ -186,7 +186,7 @@ namespace Data throw new NotImplementedException(); } - public bool EmailDisponible(string mail) + public Task EmailDisponible(string mail) { throw new NotImplementedException(); } diff --git a/Sources/IHM/IHM.csproj b/Sources/IHM/IHM.csproj index 262fcf6..1b1eaf1 100644 --- a/Sources/IHM/IHM.csproj +++ b/Sources/IHM/IHM.csproj @@ -57,7 +57,7 @@ - + diff --git a/Sources/IHM/Mobile/Dashboard.xaml.cs b/Sources/IHM/Mobile/Dashboard.xaml.cs index cf3538e..a5c526e 100644 --- a/Sources/IHM/Mobile/Dashboard.xaml.cs +++ b/Sources/IHM/Mobile/Dashboard.xaml.cs @@ -1,4 +1,5 @@ using Model; +using System.Diagnostics; namespace IHM.Mobile; @@ -17,11 +18,11 @@ public partial class DashBoard : ContentPage } - if (!Mgr.Pers.TestConnexion()) + /*if (!Mgr.Pers.TestConnexion()) { loadPage(new ErrorPage()); - - } + Debug.WriteLine("cc"); + }*/ } diff --git a/Sources/IHM/Mobile/ForgetPassword.xaml.cs b/Sources/IHM/Mobile/ForgetPassword.xaml.cs index 174ec8c..833f916 100644 --- a/Sources/IHM/Mobile/ForgetPassword.xaml.cs +++ b/Sources/IHM/Mobile/ForgetPassword.xaml.cs @@ -14,13 +14,14 @@ public partial class ForgetPassword : ContentPage { InitializeComponent(); } - public void SearchEmail(object sender, EventArgs e) + public async void SearchEmail(object sender, EventArgs e) { if (EntryMail.Text == null) { AffichError("Email inconnue", "Aucun compte existant portant cette adresse mail", "OK"); } - if (Mgr.Pers.EmailDisponible(EntryMail.Text)){ + if (await Mgr.Pers.EmailDisponible(EntryMail.Text)) + { Random generator = new Random(); code = generator.Next(0, 1000000).ToString("D6"); Email.CreateMail(EntryMail.Text, code); diff --git a/Sources/IHM/Mobile/Inscription.xaml.cs b/Sources/IHM/Mobile/Inscription.xaml.cs index 425e93b..7f40322 100644 --- a/Sources/IHM/Mobile/Inscription.xaml.cs +++ b/Sources/IHM/Mobile/Inscription.xaml.cs @@ -11,7 +11,7 @@ public partial class Inscription : ContentPage { InitializeComponent(); } - public void InscriptionOnClicked(object sender, EventArgs e) + public async void InscriptionOnClicked(object sender, EventArgs e) { if (EntryNewName.Text == null || EntryNewMail.Text == null || EntryConfirmationPassword.Text == null || EntryNewPassword.Text == null || EntryNewSurname.Text == null) @@ -21,7 +21,7 @@ public partial class Inscription : ContentPage else { if(EntryNewPassword.Text.Equals(EntryConfirmationPassword.Text)) { - if (Mgr.Pers.EmailDisponible(EntryNewMail.Text)) + if (await Mgr.Pers.EmailDisponible(EntryNewMail.Text)) { AffichError("Mail existant", "un compte porte déjà cette adresse mail, veuillez en changer", "OK"); } diff --git a/Sources/IHM/Mobile/MainPage.xaml.cs b/Sources/IHM/Mobile/MainPage.xaml.cs index 31daa44..b9d650c 100644 --- a/Sources/IHM/Mobile/MainPage.xaml.cs +++ b/Sources/IHM/Mobile/MainPage.xaml.cs @@ -9,19 +9,19 @@ namespace IHM.Mobile public MainPage() { InitializeComponent(); - //BindingContext = this; + BindingContext = this; } - public void ConnectionOnClicked(object sender, EventArgs e) + public async void ConnectionOnClicked(object sender, EventArgs e) { if (EntryMail.Text == null || EntryPassworld.Text == null) { AffichError("Champ invalide", "Veuillez compléter tout les champs", "OK"); } else { - if (Mgr.Pers.EmailDisponible(EntryMail.Text)) + if (await Mgr.Pers.EmailDisponible(EntryMail.Text)) { if (Mgr.CompareHash(Mgr.getPassword(EntryMail.Text), EntryPassworld.Text)) { diff --git a/Sources/IHM/Platforms/Android/MainApplication.cs b/Sources/IHM/Platforms/Android/MainApplication.cs index 0d0a486..bbc2ca6 100644 --- a/Sources/IHM/Platforms/Android/MainApplication.cs +++ b/Sources/IHM/Platforms/Android/MainApplication.cs @@ -3,7 +3,8 @@ using Android.Runtime; namespace IHM { - [Application] + [Application(UsesCleartextTraffic = true)] + public class MainApplication : MauiApplication { public MainApplication(IntPtr handle, JniHandleOwnership ownership) diff --git a/Sources/Modele/IPersistanceManager.cs b/Sources/Modele/IPersistanceManager.cs index 5d6992a..6b29a30 100644 --- a/Sources/Modele/IPersistanceManager.cs +++ b/Sources/Modele/IPersistanceManager.cs @@ -12,11 +12,11 @@ namespace Model // /!\ et ne doit en aucun cas manipuler la mémoire ! //actions sur les inscrits - bool AjouterInscrit(Inscrit inscrit); + Task AjouterInscrit(Inscrit inscrit); bool SupprimerInscrit(Inscrit inscrit); bool ModifierMdpInscrit(string mail, string nouveauMdp); Inscrit RecupererInscrit(string mail); - bool EmailDisponible(string mail); + Task EmailDisponible(string mail); //actions sur les banques