fix data binding issue

pull/42/head
Antoine PEREDERII 2 years ago
parent 85c2f2e5ad
commit c19df0275e

@ -15,11 +15,12 @@ public partial class App : Application
MyManager.DataLoad(); MyManager.DataLoad();
MyManager.Persistence = new DataContractPersistance.DataContractPers(); MyManager.Persistence = new DataContractPersistance.DataContractPers();
MyManager.DataSave();
InitializeComponent(); InitializeComponent();
MainPage = new AppShell(); MainPage = new AppShell();
//MyManager.DataSave();
} }
} }

@ -3,11 +3,13 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Runtime.Serialization;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Banquale.Model namespace Banquale.Model
{ {
[DataContract]
public class Account : INotifyPropertyChanged public class Account : INotifyPropertyChanged
{ {
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
@ -17,9 +19,10 @@ namespace Banquale.Model
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
} }
[DataMember]
public double Balance public double Balance
{ {
get => Balance; get => balance;
set set
{ {
if (balance == value) if (balance == value)
@ -31,7 +34,7 @@ namespace Banquale.Model
private double balance; private double balance;
[DataMember]
public string Name public string Name
{ {
get => name; get => name;
@ -45,6 +48,8 @@ namespace Banquale.Model
} }
private string name; private string name;
[DataMember]
public string IBAN public string IBAN
{ {
get => iban; get => iban;
@ -66,7 +71,8 @@ namespace Banquale.Model
IBAN = iban; IBAN = iban;
} }
public List<Transactions> TransactionsList { get; set; } [DataMember]
public List<Transactions> TransactionsList { get; set; } = new List<Transactions>();
//public bool DoTransactions(string name, string IBAN, float sum) //public bool DoTransactions(string name, string IBAN, float sum)
//{ //{
@ -97,7 +103,7 @@ namespace Banquale.Model
internal static void AskForHelp(Entry request, Entry subject, Editor message) internal static void AskForHelp(Entry request, Entry subject, Editor message)
{ {
Debug.WriteLine(request); Debug.WriteLine(request.Text);
Debug.WriteLine(subject); Debug.WriteLine(subject);
Debug.WriteLine(message); Debug.WriteLine(message);
Debug.WriteLine("Help button pressed !"); Debug.WriteLine("Help button pressed !");

@ -12,7 +12,7 @@ namespace Banquale.Model
public class Customer : Person public class Customer : Person
{ {
[DataMember] [DataMember]
public List<Account> AccountsList { get; private set; } public List<Account> AccountsList { get; private set; } = new List<Account>();
//private uint NbAccounts { get; set; } = AccountsList.Count; //private uint NbAccounts { get; set; } = AccountsList.Count;

@ -1,7 +1,9 @@
using System.ComponentModel; using System.ComponentModel;
using System.Runtime.Serialization;
namespace Banquale.Model namespace Banquale.Model
{ {
[DataContract]
public class Transactions : INotifyPropertyChanged public class Transactions : INotifyPropertyChanged
{ {
@ -9,6 +11,8 @@ namespace Banquale.Model
{ {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
} }
[DataMember]
public int Type public int Type
{ {
get => type; get => type;
@ -20,9 +24,11 @@ namespace Banquale.Model
OnPropertyChanged(nameof(Type)); OnPropertyChanged(nameof(Type));
} }
} }
[DataMember]
private int type; private int type;
[DataMember]
public Double Sum public Double Sum
{ {
get => sum; get => sum;
@ -34,8 +40,10 @@ namespace Banquale.Model
OnPropertyChanged(nameof(Sum)); OnPropertyChanged(nameof(Sum));
} }
} }
[DataMember]
private Double sum; private Double sum;
[DataMember]
public Account InvolvedAccounts public Account InvolvedAccounts
{ {
get => involvedAccounts; get => involvedAccounts;
@ -47,8 +55,10 @@ namespace Banquale.Model
OnPropertyChanged(nameof(InvolvedAccounts)); OnPropertyChanged(nameof(InvolvedAccounts));
} }
} }
[DataMember]
private Account involvedAccounts; private Account involvedAccounts;
[DataMember]
public string Category public string Category
{ {
get => category; get => category;
@ -60,8 +70,10 @@ namespace Banquale.Model
OnPropertyChanged(nameof(Category)); OnPropertyChanged(nameof(Category));
} }
} }
[DataMember]
private string category; private string category;
[DataMember]
public DateTime Date public DateTime Date
{ {
get => date; get => date;
@ -73,6 +85,7 @@ namespace Banquale.Model
OnPropertyChanged(nameof(Date)); OnPropertyChanged(nameof(Date));
} }
} }
[DataMember]
private DateTime date; private DateTime date;
public Transactions(int type, Double sum, Account involvedAccounts, string category, DateTime date) public Transactions(int type, Double sum, Account involvedAccounts, string category, DateTime date)

@ -1,4 +1,5 @@
using System; using System;
using System.Diagnostics;
using Banquale.Model; using Banquale.Model;
namespace Banquale.Stub namespace Banquale.Stub
@ -21,13 +22,24 @@ namespace Banquale.Stub
Transactions Transactions2 = new Transactions(1, 54.99, Account2, "Test", new DateTime(2022, 8, 15)); Transactions Transactions2 = new Transactions(1, 54.99, Account2, "Test", new DateTime(2022, 8, 15));
Transactions Transactions3 = new Transactions(0, 1000, Account3, "Test", new DateTime(2020, 9, 1)); Transactions Transactions3 = new Transactions(0, 1000, Account3, "Test", new DateTime(2020, 9, 1));
Console.WriteLine(Customer1); Debug.WriteLine(Customer1.Name, Customer1.Password);
List<Customer> CustomersList = new List<Customer>(); List<Customer> CustomersList = new List<Customer>();
List<Transactions> TransactionsList= new List<Transactions>(); List<Transactions> TransactionsList= new List<Transactions>();
List<Account> AcountsList = new List<Account>(); List<Account> AccountsList = new List<Account>();
AcountsList.Add(Account1);
AcountsList.Add(Account2);
AcountsList.Add(Account3);
Account1.TransactionsList.Add(Transactions1);
Account2.TransactionsList.Add(Transactions2);
//AccountsList.Add(Account1);
//AccountsList.Add(Account2);
//AccountsList.Add(Account3);
Customer1.AccountsList.Add(Account1);
Customer1.AccountsList.Add(Account2);
CustomersList.Add(Customer1); CustomersList.Add(Customer1);
CustomersList.Add(Customer2); CustomersList.Add(Customer2);

@ -42,7 +42,7 @@
TextColor="Black" TextColor="Black"
HorizontalOptions="Center"/> HorizontalOptions="Center"/>
<Label <Label
Text="{Binding AccountList[0].Balance}" Text="{Binding CustomersList[0].AccountList[0].Balance}"
Grid.Column="1" Grid.Column="1"
MinimumWidthRequest="70" MinimumWidthRequest="70"
TextColor="Black" TextColor="Black"

Loading…
Cancel
Save