C#/data_binding-contract #41

Merged
antoine.perederii merged 11 commits from C#/data_binding-contract into master 2 years ago

@ -6,11 +6,6 @@
xmlns:views="clr-namespace:Banquale.Views" xmlns:views="clr-namespace:Banquale.Views"
Shell.FlyoutBehavior="Disabled"> Shell.FlyoutBehavior="Disabled">
<!--<ShellContent
Title="Connection"
ContentTemplate="{DataTemplate views:ConnectionPage}"
Route="connection" />-->
<ShellContent ContentTemplate="{DataTemplate views:ConnectionPage}" <ShellContent ContentTemplate="{DataTemplate views:ConnectionPage}"
Route="connection"/> Route="connection"/>

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -7,14 +8,84 @@ using System.Threading.Tasks;
namespace Banquale.Model namespace Banquale.Model
{ {
public class Account public class Account : INotifyPropertyChanged
{ {
public int Balance { get; set; } public event PropertyChangedEventHandler PropertyChanged;
public string Name { get; set;} void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public string IBAN { get; set; } public double Balance
{
get => Balance;
set
{
if (balance == value)
return;
balance = value;
OnPropertyChanged(nameof(Balance));
}
}
private double balance;
public string Name
{
get => name;
set
{
if (name == value)
return;
name = value;
OnPropertyChanged(nameof(Name));
}
}
private string name;
public string IBAN
{
get => iban;
set
{
if (iban == value)
return;
iban = value;
OnPropertyChanged(nameof(IBAN));
}
}
private string iban;
public Account(int balance, string name, string iban)
{
Balance = balance;
Name = name;
IBAN = iban;
}
public List<Transactions> TransactionsList { get; set; } public List<Transactions> TransactionsList { get; set; }
//public bool DoTransactions(string name, string IBAN, float sum)
//{
// List<Transactions> transactions.add(sum);
// if ()
// return true;
//}
//public bool DoRequest(string name, string IBAN, float sum)
//{
// List<Transactions> transactions.add(sum);
// if ()
// return true;
//}
//public void AskForHelp(string type, string type2, string message)
//{
//}
} }
} }

@ -14,11 +14,15 @@ namespace Banquale.Model
[DataMember] [DataMember]
public List<Account> AccountsList { get; private set; } public List<Account> AccountsList { get; private set; }
//private unsigned int NbAccounts { get; private set; }
public Customer(string name, string firstName, string password) : base(name, firstName, password) public Customer(string name, string firstName, string password) : base(name, firstName, password)
{} {}
} }
} }

@ -10,6 +10,6 @@ namespace Banquale.Model
{ {
public (List<Customer>, List<Transactions>) DataLoad(); public (List<Customer>, List<Transactions>) DataLoad();
void DataSave(List<Customer> c, List<Transactions> t); void DataSave(List<Customer> c, List<Transactions> t /*, List<Account> c2*/);
} }
} }

@ -14,11 +14,11 @@ namespace Banquale.Model
public IPersistenceManager Persistence { get; set; } public IPersistenceManager Persistence { get; set; }
public Manager(IPersistenceManager persistance) { public Manager(IPersistenceManager persistence) {
TransactionsList = new List<Transactions>(); TransactionsList = new List<Transactions>();
CustomersList = new List<Customer>(); CustomersList = new List<Customer>();
Persistence = persistance; Persistence = persistence;
} }

@ -1,26 +1,89 @@
using System; using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Banquale.Model namespace Banquale.Model
{ {
public class Transactions public class Transactions : INotifyPropertyChanged
{ {
public int Type { get; private set; }
public int Sum { get; private set; } void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public int Type
{
get => type;
set
{
if(type == value)
return;
type = value;
OnPropertyChanged(nameof(Type));
}
}
private int type;
public Double Sum
{
get => sum;
set
{
if (sum == value)
return;
sum = value;
OnPropertyChanged(nameof(Sum));
}
}
private Double sum;
public Account InvolvedAccounts { get; private set; } public Account InvolvedAccounts
{
get => involvedAccounts;
set
{
if (involvedAccounts == value)
return;
involvedAccounts = value;
OnPropertyChanged(nameof(InvolvedAccounts));
}
}
private Account involvedAccounts;
public string Category { get; private set; } public string Category
{
get => category;
set
{
if (category == value)
return;
category = value;
OnPropertyChanged(nameof(Category));
}
}
private string category;
public Transactions(int type, int sum, Account involvedAccounts, string category) { public DateTime Date
{
get => date;
set
{
if (date == value)
return;
date = value;
OnPropertyChanged(nameof(Date));
}
}
private DateTime date;
public Transactions(int type, Double sum, Account involvedAccounts, string category, DateTime date)
{
Type = type; Type = type;
Sum = sum; Sum = sum;
InvolvedAccounts = involvedAccounts; InvolvedAccounts = involvedAccounts;
Category = category; Category = category;
Date = date;
} }
public event PropertyChangedEventHandler PropertyChanged;
} }
} }

@ -3,21 +3,36 @@ using Banquale.Model;
namespace Banquale.Stub namespace Banquale.Stub
{ {
public class Stub : IPersistenceManager public class Stub : IPersistenceManager
{ {
public (List<Customer>, List<Transactions>) DataLoad() public (List<Customer>, List<Transactions> /*, List<Account>*/) DataLoad()
{ {
Customer Customer1 = new Customer("Jacques", "Morice", "J'aimeLesFrites"); Customer Customer1 = new Customer("Jacques", "Morice", "J'aimeLesFrites");
Customer Customer2 = new Customer("Francis", "Begore", "J'aimeLes"); Customer Customer2 = new Customer("Francis", "Begore", "J'aimeLes");
Customer Customer3 = new Customer("Michel", "Boudout", "MonMdP"); Customer Customer3 = new Customer("Michel", "Boudout", "MonMdP");
Account Account1 = new Account(999, "Tatouille", "FR76 9161 9581 6296 8415 2361 004");
Account Account2 = new Account(9510, "Despoints", "FR76 4785 8569 6914 4152 5263 003");
Account Account3 = new Account(3519, "Perotte", "FR76 6352 2541 4169 6958 5847 002");
Transactions Transactions1 = new Transactions(0, 55, Account1, "Test", new DateTime(2023, 6, 21));
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));
Console.WriteLine(Customer1); Console.WriteLine(Customer1);
List<Customer> CustomersList = new List<Customer>(); List<Customer> ListeCustomers = new List<Customer>();
List<Transactions> TransactionsList = new List<Transactions>(); List<Transactions> ListeTransactions = new List<Transactions>();
CustomersList.Add(Customer1); //List<Account> ListeAccount = new List<Account>();
CustomersList.Add(Customer2); //ListeAccount.Add( Account1 );
CustomersList.Add(Customer3); //ListeAccount.Add(Account2);
return (CustomersList, TransactionsList); //ListeAccount.Add(Account3);
ListeCustomers.Add(Customer1);
ListeCustomers.Add(Customer2);
ListeCustomers.Add(Customer3);
return (ListeCustomers, ListeTransactions /*, ListeAccount*/);
} }
public void DataSave(List<Customer> c, List<Transactions> t) public void DataSave(List<Customer> c, List<Transactions> t)

@ -2,9 +2,11 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Banquale.Views" xmlns:local="clr-namespace:Banquale.Views"
xmlns:model="clr-namespace:Banquale.Model"
x:Class="Banquale.Views.BalancePage" x:Class="Banquale.Views.BalancePage"
Title="BalancePage" Title="BalancePage"
Shell.NavBarIsVisible="False"> Shell.NavBarIsVisible="False"
>
<Grid RowDefinitions="auto, *"> <Grid RowDefinitions="auto, *">
<Grid BackgroundColor="Beige" <Grid BackgroundColor="Beige"
@ -26,21 +28,24 @@
BackgroundColor="AliceBlue" BackgroundColor="AliceBlue"
Margin="0, 15, 0, 0"/> Margin="0, 15, 0, 0"/>
<Label <Label
Text="Mme Perotte" Text="{Binding Name}"
Grid.Row="1" Grid.Row="1"
Grid.ColumnSpan="2" Grid.ColumnSpan="2"
HorizontalOptions="Center" HorizontalOptions="Center"
TextColor="Black"
BackgroundColor="SaddleBrown"/> <!-- colspan permet de redefinir la taille de la colonne --> BackgroundColor="SaddleBrown"/> <!-- colspan permet de redefinir la taille de la colonne -->
<Grid ColumnDefinitions="*, *" Grid.Row="2" > <Grid ColumnDefinitions="*, *" Grid.Row="2" >
<Label <Label
Text="Solde" Text="Solde"
WidthRequest="75" WidthRequest="75"
TextColor="Black"
HorizontalOptions="Center"/> HorizontalOptions="Center"/>
<Label <Label
Text="1999,00 €" Text="{Binding Balance}"
Grid.Column="1" Grid.Column="1"
MinimumWidthRequest="70" MinimumWidthRequest="70"
TextColor="Black"
HorizontalOptions="Center"/> HorizontalOptions="Center"/>
</Grid> </Grid>

@ -4,9 +4,12 @@ namespace Banquale.Views;
public partial class BalancePage : ContentPage public partial class BalancePage : ContentPage
{ {
public BalancePage() //public Manager Mgr { get; private set; } = new Manager();
public BalancePage()
{ {
InitializeComponent(); InitializeComponent();
BindingContext = new Account(999, "Tatouille", "FR76 9161 9581 6296 8415 2361 004"); ;
} }
public async void OnButtonClicked(object sender, EventArgs e) public async void OnButtonClicked(object sender, EventArgs e)

@ -13,7 +13,8 @@
<Entry Placeholder="Destinataire" <Entry Placeholder="Destinataire"
HorizontalOptions="Center" HorizontalOptions="Center"
WidthRequest="280"/> WidthRequest="280"
x:Name="Name"/>
</Frame> </Frame>

@ -1,4 +1,5 @@
namespace Banquale.Views; using Banquale.Model;
namespace Banquale.Views;
public partial class RequestPage : ContentPage public partial class RequestPage : ContentPage
{ {
@ -12,4 +13,6 @@ public partial class RequestPage : ContentPage
// await Shell.Current.GoToAsync("//balance"); // await Shell.Current.GoToAsync("//balance");
//} //}
//Client.DoRequest(this.name, this.IBAN, )
} }

Loading…
Cancel
Save