Merge branch 'Binding' of https://codefirst.iut.uca.fr/git/ConsEcoTeam/ConsEco into Binding
continuous-integration/drone/push Build was killed Details

pull/143/head
Nicolas MAYE 2 years ago
commit d2cc90c555

@ -45,7 +45,7 @@ $app->get('/Banque/', function(Request $request, Response $response){
$app->post('/Banque/FromId/', function(Request $request, Response $response,array $args){ $app->post('/Banque/FromId/', function(Request $request, Response $response,array $args){
$id = $request->getParsedBody()["id"]; $id = $request->getParsedBody()["id"];
$query = 'SELECT * FROM Banque WHERE nom IN (SELECT nomBanque FROM InscrBanque WHERE idInscrit=:id)'; $query = 'SELECT id, nomBanque FROM InscrBanque WHERE idInscrit=:id';
try{ try{
$db = new Database(); $db = new Database();

@ -155,14 +155,14 @@ namespace Data
} }
} }
public static async Task<List<Banque>> GetBanqueAsync(string id) public static async Task<List<BanqueInscrit>> GetBanqueAsync(string id)
{ {
var dataBody = new Dictionary<string, string> { { "id", id } }; var dataBody = new Dictionary<string, string> { { "id", id } };
HttpResponseMessage reponse = await cli.PostAsJsonAsync(POST_BANQUES_INSCRIT_DATA_URL, dataBody); HttpResponseMessage reponse = await cli.PostAsJsonAsync(POST_BANQUES_INSCRIT_DATA_URL, dataBody);
if (reponse.IsSuccessStatusCode) if (reponse.IsSuccessStatusCode)
{ {
return JsonConvert.DeserializeObject<List<Banque>>(await reponse.Content.ReadAsStringAsync()); return JsonConvert.DeserializeObject<List<BanqueInscrit>>(await reponse.Content.ReadAsStringAsync());
} }
else else
{ {
@ -357,7 +357,7 @@ namespace Data
var dataBody = new Dictionary<string, string> var dataBody = new Dictionary<string, string>
{ {
{ "compte", compte.Identifiant }, { "compte", compte.Identifiant },
{ "nom", planification.IntituleOperation }, { "nom", planification.Nom },
{ "montant", planification.Montant.ToString() }, { "montant", planification.Montant.ToString() },
{ "dateO", planification.DateOperation.ToString() }, { "dateO", planification.DateOperation.ToString() },
{ "methodePayement", planification.ModePayement.ToString() }, { "methodePayement", planification.ModePayement.ToString() },

@ -56,7 +56,7 @@ namespace Data
{ {
return await ClientAPI.DeleteBanqueInscritAsync(banque.Nom, inscrit.Id.ToString()); return await ClientAPI.DeleteBanqueInscritAsync(banque.Nom, inscrit.Id.ToString());
} }
public async Task<IList<Banque>> RecupererBanques(Inscrit inscrit) public async Task<IList<BanqueInscrit>> RecupererBanques(Inscrit inscrit)
{ {
return await ClientAPI.GetBanqueAsync(inscrit.Id.ToString()); return await ClientAPI.GetBanqueAsync(inscrit.Id.ToString());
} }
@ -75,9 +75,9 @@ namespace Data
{ {
return await ClientAPI.DeleteCompteInscritAsync(compte.Nom, inscrit.Id.ToString()); return await ClientAPI.DeleteCompteInscritAsync(compte.Nom, inscrit.Id.ToString());
} }
public async Task<IList<Compte>> RecupererCompte(Banque banque, Inscrit inscrit) public async Task<IList<Compte>> RecupererCompte(BanqueInscrit banque)
{ {
return await ClientAPI.GetCompteAsync(inscrit.Id.ToString()); return await ClientAPI.GetCompteAsync(banque.Id.ToString());
} }
@ -103,7 +103,7 @@ namespace Data
} }
public async Task<bool> SupprimerPlanification(Compte compte, Planification planification) public async Task<bool> SupprimerPlanification(Compte compte, Planification planification)
{ {
return await ClientAPI.DeletePlanificationInscritAsync(compte.Identifiant, planification.IntituleOperation); return await ClientAPI.DeletePlanificationInscritAsync(compte.Identifiant, planification.Nom);
} }
public async Task<IList<Planification>> RecupererPlanification(Compte compte) public async Task<IList<Planification>> RecupererPlanification(Compte compte)
{ {

@ -201,7 +201,7 @@ namespace Data
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<IList<Banque>> RecupererBanques(Inscrit inscrit) public Task<IList<BanqueInscrit>> RecupererBanques(Inscrit inscrit)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@ -211,7 +211,7 @@ namespace Data
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<IList<Compte>> RecupererCompte(Banque banque, Inscrit inscrit) public Task<IList<Compte>> RecupererCompte(BanqueInscrit banque)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

@ -84,7 +84,7 @@
<Label Grid.Column="0" Text="{Binding IntituleOperation}" <Label Grid.Column="0" Text="{Binding Nom}"
TextColor="{StaticResource Secondary}" TextColor="{StaticResource Secondary}"
FontAttributes="Bold" FontSize="Body" FontAttributes="Bold" FontSize="Body"
HorizontalOptions="Center" HorizontalOptions="Center"

@ -14,9 +14,9 @@ public partial class CV_Planification : ContentView
{ {
InitializeComponent(); InitializeComponent();
/* Mgr.LoadBanque(); Mgr.LoadBanque();
Mgr.LoadCompte(); Mgr.LoadCompte();
*/
BindingContext = Mgr; BindingContext = Mgr;
} }

@ -11,7 +11,7 @@ public partial class AjoutBanques : ContentPage
{ {
InitializeComponent(); InitializeComponent();
BindingContext = Mgr; BindingContext = Mgr;
Mgr.LoadBanques(); //Mgr.LoadBanques();
if (OperatingSystem.IsIOS()) if (OperatingSystem.IsIOS())
{ {
boutonRetour.IsVisible = true; boutonRetour.IsVisible = true;
@ -71,7 +71,7 @@ public partial class AjoutBanques : ContentPage
} }
} }
Mgr.User.LesBanques = await Mgr.Pers.RecupererBanques(Mgr.User); //Mgr.User.LesBanques = await Mgr.Pers.RecupererBanques(Mgr.User);
await Navigation.PopModalAsync(); await Navigation.PopModalAsync();
} }
} }

@ -11,7 +11,7 @@ public partial class GestionBanques : ContentPage
{ {
InitializeComponent(); InitializeComponent();
BindingContext= Mgr; BindingContext= Mgr;
Mgr.LoadBanques(); //Mgr.LoadBanques();
if (OperatingSystem.IsIOS()) if (OperatingSystem.IsIOS())
{ {
boutonRetour.IsVisible = true; boutonRetour.IsVisible = true;

@ -28,7 +28,7 @@ namespace IHM.Mobile
Mgr.createUser(EntryMail.Text); Mgr.createUser(EntryMail.Text);
await Navigation.PopModalAsync(); await Navigation.PopModalAsync();
Mgr.LoadBanques(); //Mgr.LoadBanques();
} }
else else
{ {

@ -11,6 +11,7 @@ namespace Model
public class Banque : INotifyPropertyChanged public class Banque : INotifyPropertyChanged
{ {
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
public string Nom { get; private set; } public string Nom { get; private set; }
/// <summary> /// <summary>
@ -49,10 +50,10 @@ namespace Model
ListeDesComptes = lescomptes; ListeDesComptes = lescomptes;
} }
/* public Banque() /* public Banque()
{ {
} }
*/ */
void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
public void AjouterCompte(Compte compte) public void AjouterCompte(Compte compte)
{ {

@ -0,0 +1,27 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class BanqueInscrit
{
public int Id { get; private set; }
public string Name { get; private set; }
[JsonConstructor]
public BanqueInscrit(int id, string name)
{
Id = id;
Name = name;
}
public override string ToString()
{
return Id + " " + Name;
}
}
}

@ -22,14 +22,14 @@ namespace Model
//actions sur les banques //actions sur les banques
Task<bool> AjouterBanque(Banque banque, Inscrit inscrit); Task<bool> AjouterBanque(Banque banque, Inscrit inscrit);
Task<bool> SupprimerBanque(Banque banque, Inscrit inscrit); Task<bool> SupprimerBanque(Banque banque, Inscrit inscrit);
Task<IList<Banque>> RecupererBanques(Inscrit inscrit); Task<IList<BanqueInscrit>> RecupererBanques(Inscrit inscrit);
Task<IList<Banque>> RecupererBanquesDisponible(); Task<IList<Banque>> RecupererBanquesDisponible();
//actions sur les comptes //actions sur les comptes
Task<bool> AjouterCompte(Compte compte, Inscrit inscrit); Task<bool> AjouterCompte(Compte compte, Inscrit inscrit);
Task<bool> SupprimerCompte(Compte compte, Inscrit inscrit); Task<bool> SupprimerCompte(Compte compte, Inscrit inscrit);
Task<IList<Compte>> RecupererCompte(Banque banque, Inscrit inscrit); Task<IList<Compte>> RecupererCompte(BanqueInscrit banque);
//actions sur les Opérations //actions sur les Opérations

@ -26,13 +26,13 @@ namespace Model
{ {
user = value; user = value;
OnPropertyChanged(nameof(User)); OnPropertyChanged(nameof(User));
LoadBanque();
} }
} }
} }
private Inscrit user; private Inscrit user;
public Banque SelectedBanque public BanqueInscrit SelectedBanque
{ {
get => selectedBanque; get => selectedBanque;
set set
@ -44,8 +44,7 @@ namespace Model
} }
} }
} }
private Banque selectedBanque; private BanqueInscrit selectedBanque;
public IList<Banque> BanquesDisponibleInApp public IList<Banque> BanquesDisponibleInApp
{ {
get => banquesDisponibleInApp; get => banquesDisponibleInApp;
@ -77,8 +76,8 @@ namespace Model
private Compte selectedCompte; private Compte selectedCompte;
private IList<Banque> listeDesBanques = new List<Banque>(); private IList<BanqueInscrit> listeDesBanques = new List<BanqueInscrit>();
public ReadOnlyCollection<Banque> AllBanque { get; private set; } public ReadOnlyCollection<BanqueInscrit> AllBanque { get; private set; }
private List<Compte> listeDesComptes = new List<Compte>(); private List<Compte> listeDesComptes = new List<Compte>();
@ -88,7 +87,7 @@ namespace Model
public Manager(IPersistanceManager persistance) public Manager(IPersistanceManager persistance)
{ {
AllBanque = new ReadOnlyCollection<Banque>(listeDesBanques); AllBanque = new ReadOnlyCollection<BanqueInscrit>(listeDesBanques);
AllCompte = new ReadOnlyCollection<Compte>(listeDesComptes); AllCompte = new ReadOnlyCollection<Compte>(listeDesComptes);
Pers = persistance; Pers = persistance;
} }
@ -99,6 +98,7 @@ namespace Model
public async void LoadCompte() public async void LoadCompte()
{ {
listeDesComptes.Clear(); listeDesComptes.Clear();
if(SelectedBanque == null) if(SelectedBanque == null)
@ -108,7 +108,7 @@ namespace Model
try try
{ {
IList<Compte> comptes = await Pers.RecupererCompte(SelectedBanque, User); IList<Compte> comptes = await Pers.RecupererCompte(SelectedBanque);
listeDesComptes.AddRange(comptes); listeDesComptes.AddRange(comptes);
} }
catch(Exception exception) catch(Exception exception)
@ -139,7 +139,7 @@ namespace Model
selectedCompte = listeDesComptes.First(); selectedCompte = listeDesComptes.First();
} }
SelectedCompte = listeDesComptes.FirstOrDefault();
} }
@ -148,14 +148,12 @@ namespace Model
try try
{ {
listeDesBanques = await Pers.RecupererBanques(User); listeDesBanques = await Pers.RecupererBanques(User);
}catch(Exception exception) SelectedBanque = listeDesBanques.FirstOrDefault();
{
Debug.WriteLine(exception.Message);
}
if(listeDesBanques.Count > 0) }
catch (Exception exception)
{ {
SelectedBanque = listeDesBanques.First(); Debug.WriteLine(exception.Message);
} }
} }
@ -187,11 +185,11 @@ namespace Model
User = null; User = null;
} }
public async void LoadBanques() /*public async void LoadBanques()
{ {
User.LesBanques = await Pers.RecupererBanques(User); User.LesBanques = await Pers.RecupererBanques(User);
BanquesDisponibleInApp = await Pers.RecupererBanquesDisponible(); BanquesDisponibleInApp = await Pers.RecupererBanquesDisponible();
} }*/
public async Task<string> getPassword(string email) public async Task<string> getPassword(string email)
{ {

@ -12,7 +12,7 @@ namespace Model
public class Planification public class Planification
{ {
public string IntituleOperation { get; private set; } public string Nom { get; private set; }
public double Montant { get; private set; } public double Montant { get; private set; }
@ -24,9 +24,9 @@ namespace Model
public TagOperation Tag { get; private set; } public TagOperation Tag { get; private set; }
[JsonConstructor] [JsonConstructor]
public Planification(string intituleOperation, double montant, DateTime dateOperation, MethodePayement modePayement, TagOperation tag, bool isDebit = true) public Planification(string nom, double montant, DateTime dateOperation, MethodePayement modePayement, TagOperation tag, bool isDebit = true)
{ {
IntituleOperation = intituleOperation; Nom = nom;
Montant = montant; Montant = montant;
DateOperation = dateOperation; DateOperation = dateOperation;
ModePayement = modePayement; ModePayement = modePayement;
@ -36,7 +36,7 @@ namespace Model
public override string ToString() public override string ToString()
{ {
return IntituleOperation + " " + DateOperation + " " + Montant + " " + ModePayement + " " + IsDebit + " " + Tag; return Nom + " " + DateOperation + " " + Montant + " " + ModePayement + " " + IsDebit + " " + Tag;
} }
} }
} }

@ -2,6 +2,7 @@
using Model; using Model;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Syncfusion.Maui.DataSource.Extensions;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Security.Principal; using System.Security.Principal;
using System.Xml.Linq; using System.Xml.Linq;
@ -87,8 +88,8 @@ foreach (Banque b in banques)
Console.WriteLine("\n--------\n"); Console.WriteLine("\n--------\n");
IList<Banque> banquesId1 = ClientAPI.GetBanqueAsync("1").GetAwaiter().GetResult(); IList<BanqueInscrit> banquesId1 = ClientAPI.GetBanqueAsync("1").GetAwaiter().GetResult();
foreach (Banque b in banquesId1) foreach (BanqueInscrit b in banquesId1)
{ {
Console.WriteLine(b); Console.WriteLine(b);
} }
@ -101,7 +102,7 @@ Console.WriteLine("Add banque for user : " + rrrr + "\n");
Console.WriteLine("\n----Verif----\n"); Console.WriteLine("\n----Verif----\n");
banquesId1 = ClientAPI.GetBanqueAsync("1").GetAwaiter().GetResult(); banquesId1 = ClientAPI.GetBanqueAsync("1").GetAwaiter().GetResult();
foreach (Banque b in banquesId1) foreach (BanqueInscrit b in banquesId1)
{ {
Console.WriteLine(b); Console.WriteLine(b);
} }
@ -114,7 +115,7 @@ Console.WriteLine("Del banque for user : " + rrrrrr + "\n");
Console.WriteLine("\n----Verif----\n"); Console.WriteLine("\n----Verif----\n");
banquesId1 = ClientAPI.GetBanqueAsync("1").GetAwaiter().GetResult(); banquesId1 = ClientAPI.GetBanqueAsync("1").GetAwaiter().GetResult();
foreach (Banque b in banquesId1) foreach (BanqueInscrit b in banquesId1)
{ {
Console.WriteLine(b); Console.WriteLine(b);
} }
@ -246,3 +247,14 @@ foreach (Echeance e in echeances)
{ {
Console.WriteLine(e); Console.WriteLine(e);
} }
Console.WriteLine("errr");
// test pers API
IPersistanceManager Pers = new PersAPI();
IList<Compte> bla = Pers.RecupererCompte(new BanqueInscrit(34,"BANQUE POSTALE")).GetAwaiter().GetResult();
bla.ForEach(c=> Console.WriteLine(c));

Loading…
Cancel
Save