You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ConsEco/Sources/Modele/Manager.cs

125 lines
3.1 KiB

using System.ComponentModel;
2 years ago
using System.Diagnostics;
namespace Model
{
public class Manager : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public IPersistanceManager Pers { get; private set; }
public string SelectedInscrit { get; set; }
public Hash hash = new Hash();
public int Solde
{
get => solde;
set
{
if(solde != value)
{
solde = value;
OnPropertyChanged(nameof(Solde));
}
}
}
private int solde;
public Inscrit User { get; set; }
public Banque SelectedBanque
{
get => selectedBanque;
set
{
if(selectedBanque != value)
{
selectedBanque = value;
2 years ago
OnPropertyChanged(nameof(SelectedBanque));
}
}
}
private Banque selectedBanque;
2 years ago
public IEnumerable<Banque> listeBanqueConnecte { get; private set; }
void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
public Manager(IPersistanceManager persistance)
{
Pers = persistance;
}
public void SupprimerInscritBdd(Inscrit i)
{
Pers.SupprimerInscritBdd(i);
}
public void LoadInscrit(string id, string mdp)
{
SelectedInscrit = Pers.LoadInscrit(id, mdp);
2 years ago
Debug.WriteLine(SelectedInscrit);
}
2 years ago
public void LoadBanques()
{
listeBanqueConnecte = Pers.LoadBanqueId(SelectedInscrit);
}
public void supprimerToutesBanquesBdd(Inscrit inscrit)
{
Pers.SupprimerToutesBanquesBdd(inscrit);
}
public void createInscrit(Inscrit inscrit)
{
Pers.CreateInscrit(inscrit);
}
public string lastInscrit()
{
return Pers.LastInscrit();
}
public bool existEmail(string mail)
{
return Pers.ExistEmail(mail);
}
public void changePasswordBdd(string mail, string newMdp)
{
Pers.ChangePasswordBdd(mail, newMdp);
}
public string recupMdpBdd(string mail)
{
return Pers.RecupMdpBdd(mail);
}
public bool isEqualHash(string mdpBdd, string mdpSent)
{
return hash.IsEqualHash(mdpBdd, mdpSent);
}
public void createUser(string mail)
{
User = new Inscrit(mail);
}
public int recupTotalSolde()
{
Solde = Pers.CalculTotalSoldeComtpe(User);
return Solde;
}
2 years ago
public void deconnexion()
{
SelectedBanque= null;
SelectedInscrit = null;
listeBanqueConnecte = new List<Banque>();
Debug.WriteLine(listeBanqueConnecte.Count());
}
}
}