diff --git a/Sources/IHM/Mobile/AjoutBanques.xaml b/Sources/IHM/Mobile/AjoutBanques.xaml index 6109712..24616e5 100644 --- a/Sources/IHM/Mobile/AjoutBanques.xaml +++ b/Sources/IHM/Mobile/AjoutBanques.xaml @@ -66,7 +66,8 @@ + BackgroundColor="{StaticResource Primary}" + Clicked="AddBanque_Clicked"/> diff --git a/Sources/IHM/Mobile/AjoutBanques.xaml.cs b/Sources/IHM/Mobile/AjoutBanques.xaml.cs index fd4e7d6..8b70e66 100644 --- a/Sources/IHM/Mobile/AjoutBanques.xaml.cs +++ b/Sources/IHM/Mobile/AjoutBanques.xaml.cs @@ -11,7 +11,7 @@ public partial class AjoutBanques : ContentPage { InitializeComponent(); BindingContext = Mgr; - //Mgr.importBanques(); + Mgr.LoadBanques(); if (OperatingSystem.IsIOS()) { boutonRetour.IsVisible = true; @@ -33,7 +33,11 @@ public partial class AjoutBanques : ContentPage Debug.WriteLine(lesComptes.Count); foreach(Compte compte in lesComptes) { - Mgr.User.LesBanques.First().AjouterCompte(compte); + if(Mgr.User.LesBanques.Count != 0) + { + Mgr.User.LesBanques.First().AjouterCompte(compte); + } + } } @@ -54,5 +58,21 @@ public partial class AjoutBanques : ContentPage { await Navigation.PopModalAsync(); } + + private async void AddBanque_Clicked(object sender, EventArgs e) + { + ImageButton imageButton = (ImageButton)sender; + Grid grid = (Grid)imageButton.Parent; + foreach(IView iw in grid.Children) + { + if (iw.GetType() == typeof(Label)) + { + await Mgr.Pers.AjouterBanque((Banque)(iw as Label).BindingContext, Mgr.User); + } + } + + Mgr.User.LesBanques = await Mgr.Pers.RecupererBanques(Mgr.User); + await Navigation.PopModalAsync(); + } } diff --git a/Sources/IHM/Mobile/MainPage.xaml.cs b/Sources/IHM/Mobile/MainPage.xaml.cs index c604746..848cf93 100644 --- a/Sources/IHM/Mobile/MainPage.xaml.cs +++ b/Sources/IHM/Mobile/MainPage.xaml.cs @@ -26,7 +26,7 @@ namespace IHM.Mobile if (Mgr.CompareHash(await Mgr.getPassword(EntryMail.Text), EntryPassworld.Text)) { Mgr.createUser(EntryMail.Text); - ConnexionValide(); + await Navigation.PopModalAsync(); } else { @@ -40,12 +40,6 @@ namespace IHM.Mobile } } - private async void ConnexionValide() - { - //Mgr.LoadBanques(); - await Navigation.PopModalAsync(); - } - private async void AffichError(string s, string s1, string s2) { await DisplayAlert(s, s1, s2); diff --git a/Sources/IHM/Mobile/Operations.xaml b/Sources/IHM/Mobile/Operations.xaml index 7e65976..833b44d 100644 --- a/Sources/IHM/Mobile/Operations.xaml +++ b/Sources/IHM/Mobile/Operations.xaml @@ -3,8 +3,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="IHM.Mobile.Operations"> - - + + @@ -34,7 +34,7 @@ FontAttributes="Bold"/> - - + + \ No newline at end of file diff --git a/Sources/Modele/Banque.cs b/Sources/Modele/Banque.cs index 39f9820..a4e497b 100644 --- a/Sources/Modele/Banque.cs +++ b/Sources/Modele/Banque.cs @@ -36,11 +36,8 @@ namespace Model UrlLogo = urlLogo; } - public Banque(string nom, string urlSite, string urlLogo, List lescomptes) + public Banque(string nom, string urlSite, string urlLogo, List lescomptes) : this(nom,urlSite, urlLogo) { - Nom = nom; - UrlSite = urlSite; - UrlLogo = urlLogo; ListeDesComptes = lescomptes; } diff --git a/Sources/Modele/Inscrit.cs b/Sources/Modele/Inscrit.cs index 69ff5fd..9b07cc5 100644 --- a/Sources/Modele/Inscrit.cs +++ b/Sources/Modele/Inscrit.cs @@ -64,7 +64,7 @@ namespace Model public double SoldeTotal { get; private set; } public Devises Dev { get; private set; } - public List LesBanques + public IList LesBanques { get => lesBanques; set @@ -77,7 +77,7 @@ namespace Model } } - private List lesBanques; + private IList lesBanques; [JsonConstructor] public Inscrit(int id, string nom, string mail, string prenom, string mdp, double soldeTotal = 0) @@ -88,7 +88,7 @@ namespace Model Prenom = prenom; Mdp = mdp; SoldeTotal = soldeTotal; - lesBanques = new(); + lesBanques = new List(); } public Inscrit(int id, string nom, string mail, string prenom, string mdp, double soldeTotal, List lesbanques) : this(id, nom, mail, prenom, mdp, soldeTotal) diff --git a/Sources/Modele/Manager.cs b/Sources/Modele/Manager.cs index d0e7000..152302f 100644 --- a/Sources/Modele/Manager.cs +++ b/Sources/Modele/Manager.cs @@ -9,8 +9,6 @@ namespace Model public event PropertyChangedEventHandler PropertyChanged; public IPersistanceManager Pers { get; private set; } - public int SelectedInscrit { get; set; } - private Inscrit user; public Inscrit User { @@ -75,6 +73,7 @@ namespace Model public async void LoadBanques() { + User.LesBanques = await Pers.RecupererBanques(User); BanquesDisponibleInApp = await Pers.RecupererBanquesDisponible(); }