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.
74 lines
1.9 KiB
74 lines
1.9 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.Serialization;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CanYouBuildIt.Model
|
|
{
|
|
public class Manager
|
|
{
|
|
public List<Utilisateur> listUtil { get; private set; }
|
|
public List<Composant> listComp { get; private set; }
|
|
public IPersistanceManager Persi { get; set; }
|
|
|
|
public Manager()
|
|
{
|
|
listUtil = new List<Utilisateur>();
|
|
listComp = new List<Composant>();
|
|
}
|
|
public Manager(IPersistanceManager pers)
|
|
{
|
|
listUtil = new List<Utilisateur>();
|
|
Persi = pers;
|
|
}
|
|
|
|
public void chargeDonne()
|
|
{
|
|
var donnee = Persi.chargeDonnee();
|
|
listUtil.AddRange(donnee.Item1);
|
|
listComp.AddRange(donnee.Item2);
|
|
}
|
|
|
|
public void sauvegardeDonnee()
|
|
{
|
|
Persi.sauvegardeDonnee(listUtil,listComp);
|
|
}
|
|
|
|
public void ajouterUtilisateur(Utilisateur utilisateur)
|
|
{
|
|
listUtil.Add(utilisateur);
|
|
}
|
|
|
|
public void ajouterComposant(Composant composant)
|
|
{
|
|
listComp.Add(composant);
|
|
}
|
|
|
|
public int rechercheUsername(string usern)
|
|
{
|
|
for (int i = 0; i < listUtil.Count; i++ )
|
|
{
|
|
if (listUtil[i].username.Equals(usern,StringComparison.OrdinalIgnoreCase)){
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public int recherchePwd(string pwd)
|
|
{
|
|
for (int i = 0; i < listUtil.Count; i++)
|
|
{
|
|
if (listUtil[i].password.Equals(pwd,StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
}
|
|
}
|