diff --git a/Sources/Data/PersLinqToPgSQL.cs b/Sources/Data/PersLinqToPgSQL.cs index ce7250b..591609e 100644 --- a/Sources/Data/PersLinqToPgSQL.cs +++ b/Sources/Data/PersLinqToPgSQL.cs @@ -427,7 +427,14 @@ namespace LinqToPgSQL return bquesDispo; } + public Inscrit GetInscrit(string mail) + { + throw new NotImplementedException(); + } - + public IList GetCompteFromOFX(string ofx) + { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/Sources/Data/Stub.cs b/Sources/Data/Stub.cs new file mode 100644 index 0000000..dcf99c2 --- /dev/null +++ b/Sources/Data/Stub.cs @@ -0,0 +1,82 @@ +using Model; + +namespace Data +{ + public class Stub : IPersistanceManager + { + public string GetId(string mail) + { + return "1"; + } + public void SupprimerInscritBdd(Inscrit inscrit) + { + throw new NotImplementedException(); + } + public void SupprimerBanqueBdd(Inscrit inscrit, Banque banque) + { + throw new NotImplementedException(); + } + public void SupprimerToutesBanquesBdd(Inscrit inscrit) + { + throw new NotImplementedException(); + } + public void CreateInscrit(Inscrit inscrit){} + public string LastInscrit() + { + return "1"; + } + public bool ExistEmail(string mail) + { + return true; + } + public void ChangePasswordBdd(string mail, string newMdp) + { + throw new NotImplementedException(); + } + public string RecupMdpBdd(string mail) + { + return "61202106183104184172149183829180134166241997147151111351903525172892257223616564213999421532841808077145252175106506275806214514321147161111472321892055913517616241"; + } + public int CalculTotalSoldeComtpe(Inscrit user) + { + return 0; + } + public List LoadBanqueId(string id) + { + List lesBanques = new List(); + lesBanques.Add(new Banque("Credit Agricole","azerty.com","aaacom")); + lesBanques.Add(new Banque("Credit Mutuel", "azerty.com", "aaacom")); + return lesBanques; + } + public bool TestConnexionAsDatabase() + { + return true; + } + public List ImportBanques() + { + List lesBanques = new List(); + lesBanques.Add(new Banque("Credit Agricole", "azerty.com", "aaacom")); + lesBanques.Add(new Banque("Credit Mutuel", "azerty.com", "aaacom")); + lesBanques.Add(new Banque("CIC", "azerty.com", "aaacom")); + lesBanques.Add(new Banque("BNP", "azerty.com", "aaacom")); + lesBanques.Add(new Banque("OrangeBank", "azerty.com", "aaacom")); + return lesBanques; + } + + public Inscrit GetInscrit(string mail) + { + string mdp = "Azerty12345678!"; + Inscrit i = new Inscrit("1", "LIVET", "livet.hugo2003@gmail.com", "Hugo", mdp); + + return i; + } + + public IList GetCompteFromOFX(string ofx) + { + return LoadOperation.LoadOperationsFromOFX(ofx); + } + } +} + + + diff --git a/Sources/IHM/App.xaml.cs b/Sources/IHM/App.xaml.cs index 2f0051b..ef859b9 100644 --- a/Sources/IHM/App.xaml.cs +++ b/Sources/IHM/App.xaml.cs @@ -1,11 +1,12 @@ -using LinqToPgSQL; +using Data; +using LinqToPgSQL; using Model; namespace IHM { public partial class App : Application { - public Manager Manager { get; set; } = new Manager(new PersLinqToPgSQL()); + public Manager Manager { get; set; } = new Manager(new Stub()); public App() { InitializeComponent(); diff --git a/Sources/IHM/Mobile/AjoutBanques.xaml.cs b/Sources/IHM/Mobile/AjoutBanques.xaml.cs index 9b634f9..771d317 100644 --- a/Sources/IHM/Mobile/AjoutBanques.xaml.cs +++ b/Sources/IHM/Mobile/AjoutBanques.xaml.cs @@ -1,5 +1,6 @@ using Model; using System.Diagnostics; +using System.Numerics; namespace IHM.Mobile; @@ -18,19 +19,33 @@ public partial class AjoutBanques : ContentPage PickOptions options = new PickOptions(); options.PickerTitle = "Choisir un fichier OFX"; - var result = await FilePicker.Default.PickAsync(options); - if (result != null) - { - if (result.FileName.EndsWith("ofx", StringComparison.OrdinalIgnoreCase)) + try{ + var result = await FilePicker.Default.PickAsync(options); + if (result != null) { - string file = File.ReadAllText(result.FullPath).ToString(); - //return file; + if (result.FileName.EndsWith("ofx", StringComparison.OrdinalIgnoreCase)) + { + IList lesComptes = Mgr.getCompteFromOFX(result.FullPath); + Debug.WriteLine(lesComptes.Count); + foreach(Compte compte in lesComptes) + { + Mgr.User.LesBanques.First().AjouterCompte(compte); + } + + } } + else + { + throw new FileLoadException("Imposible de charger le fichier"); + } + + } - else + catch(Exception ex) { - throw new FileLoadException("Imposible de charger le fichier"); + Debug.WriteLine(ex.Message); } + } diff --git a/Sources/IHM/Mobile/Operations.xaml b/Sources/IHM/Mobile/Operations.xaml index b4b07ff..aecd678 100644 --- a/Sources/IHM/Mobile/Operations.xaml +++ b/Sources/IHM/Mobile/Operations.xaml @@ -3,6 +3,42 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="IHM.Mobile.Operations"> + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Sources/Modele/Banque.cs b/Sources/Modele/Banque.cs index 18180f9..08b003f 100644 --- a/Sources/Modele/Banque.cs +++ b/Sources/Modele/Banque.cs @@ -1,17 +1,31 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Model { - public class Banque + public class Banque : INotifyPropertyChanged { + public event PropertyChangedEventHandler PropertyChanged; public string Nom { get; private set; } public string UrlSite { get; private set; } public string UrlLogo { get; private set; } - public List ListeDesComptes { get; private set; } = new List(); + public List ListeDesComptes + { + get => listeDesComptes; + set + { + if (listeDesComptes != value) + { + listeDesComptes = value; + OnPropertyChanged(nameof(ListeDesComptes)); + } + } + } + private List listeDesComptes = new List(); public Banque(string nom, string urlSite, string urlLogo) { @@ -28,6 +42,7 @@ namespace Model ListeDesComptes = lescomptes; } + void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); public void AjouterCompte(Compte compte) { ListeDesComptes.Add(compte); diff --git a/Sources/Modele/Compte.cs b/Sources/Modele/Compte.cs index fa7c7cd..4282bc4 100644 --- a/Sources/Modele/Compte.cs +++ b/Sources/Modele/Compte.cs @@ -1,14 +1,29 @@ using Microsoft.Maui.Graphics; +using System.Collections.Specialized; +using System.ComponentModel; namespace Model { - public class Compte + public class Compte : INotifyPropertyChanged { + public event PropertyChangedEventHandler PropertyChanged; public string Identifiant { get; set; } public string Nom { get; set; } public double Solde { get; set; } public DateTime DerniereModification { get; set; } - public List LesOpe { get; set; } = new List(); + public List LesOpe + { + get => lesOpe; + set + { + if (lesOpe != value) + { + lesOpe = value; + OnPropertyChanged(nameof(LesOpe)); + } + } + } + private List lesOpe = new List(); public List LesPla { get; set; } = new List(); public List LesEch { get; set; } = new List(); public Compte(string id,string nom, double solde) @@ -31,6 +46,9 @@ namespace Model LesEch = lesEch; } + + void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + public void ajouterOperation(Operation o) { if (o == null) throw new NullReferenceException(); diff --git a/Sources/Modele/IPersistanceManager.cs b/Sources/Modele/IPersistanceManager.cs index f9e13c5..47be43b 100644 --- a/Sources/Modele/IPersistanceManager.cs +++ b/Sources/Modele/IPersistanceManager.cs @@ -21,5 +21,8 @@ namespace Model List LoadBanqueId(string id); public bool TestConnexionAsDatabase(); public List ImportBanques(); + public Inscrit GetInscrit(string mail); + + public IList GetCompteFromOFX(string ofx); } } diff --git a/Sources/Modele/Manager.cs b/Sources/Modele/Manager.cs index b28790b..012177c 100644 --- a/Sources/Modele/Manager.cs +++ b/Sources/Modele/Manager.cs @@ -138,7 +138,8 @@ namespace Model public void createUser(string mail) { - User = new Inscrit(mail, GetId(mail)); + //User = new Inscrit(mail, GetId(mail)); + User = Pers.GetInscrit(mail); } public int recupTotalSolde() @@ -162,6 +163,11 @@ namespace Model BanquesDisponibleInApp = Pers.ImportBanques(); } + public IList getCompteFromOFX(string ofx) + { + return Pers.GetCompteFromOFX(ofx); + } + } } diff --git a/Sources/Modele/Operation.cs b/Sources/Modele/Operation.cs index 6eb429e..d8b229f 100644 --- a/Sources/Modele/Operation.cs +++ b/Sources/Modele/Operation.cs @@ -1,15 +1,28 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Model { - public class Operation + public class Operation : INotifyPropertyChanged { - - public string IntituleOperation { get; private set; } + public event PropertyChangedEventHandler PropertyChanged; + public string IntituleOperation + { + get => intituleOperation; + set + { + if (intituleOperation != value) + { + intituleOperation = value; + OnPropertyChanged(nameof(IntituleOperation)); + } + } + } + private string intituleOperation; public double Montant { get; private set; } @@ -28,6 +41,8 @@ namespace Model IsDebit = isDebit; } + void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + public override string ToString() { return IntituleOperation + " " + DateOperation + " " + Montant + " " + ModePayement + " " + IsDebit + "\n"; diff --git a/Sources/Modele/Stub.cs b/Sources/Modele/Stub.cs deleted file mode 100644 index 49d4819..0000000 --- a/Sources/Modele/Stub.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Model -{ - public class Stub //la classe n'implémante pas IPersistanceManager - { - public List Banques = new(); - public List Inscrits = new(); - public List Comptes = new(); - // - - - // ajouter load all pour tout les inscrits - - public List LoadInscrit() - { - Inscrits.Add(new("00001", "Evard", "lucasevard@gmail.com","Lucas","test",10,LoadBanques())); - Inscrits.Add(new("00002", "Livet", "hugolivet@gmail.com", "Hugo", "test", 280,LoadBanques())); - Inscrits.Add(new("00003", "Smith", "smith@gmail.com", "Luke", "test", 150,LoadBanques())); - Inscrits.Add(new("00004", "Jean", "jean@gmail.com", "sylvain", "test", 410,LoadBanques())); - Inscrits.Add(new("00005", "Franc", "franc@gmail.com", "Julie", "test", 820,LoadBanques())); - Inscrits.Add(new("00006", "March", "march@gmail.com", "bastien", "test", 1120,LoadBanques())); - return Inscrits; - } - - public List LoadBanques() - { - Banques.Add(new("BNP Paribas", "https://mabanque.bnpparibas/", "https://logos-marques.com/wp-content/uploads/2020/12/BNP-Paribas-logo.png",LoadCompte())); - Banques.Add(new("Crédit Agricole", "https://www.credit-agricole.fr", "https://yt3.ggpht.com/a/AGF-l7_mEfX2eQaGm8GefLOg5ZMRciNw-pESE3gUWg=s900-c-k-c0xffffffff-no-rj-mo",LoadCompte())); - return Banques; - } - - public List LoadCompte() - { - Comptes.Add(new("012345678901", "Livret A", 1500)); - Comptes.Add(new("012345678902", "Compte Courant", 2000)); - Comptes.Add(new("012345678903", "PEL", 22000)); - return Comptes; - } - - - } -} -