//Mise à jour d'un administrateur "a" passé en paramètre public static bool Update(Administrateur a) { OdawaDS.administrateursDataTable dt = DataProvider.GetAdministrateurs(); //Création d'une administrateursRow et remplissage avec les attributs de "a" OdawaDS.administrateursRow updRow = DataProvider.odawa.administrateurs.NewadministrateursRow(); updRow.id = a.id; updRow.nom = a.nom.ToUpper(); updRow.prenom = a.prenom; updRow.username = a.username.ToLower(); updRow.password = a.password.ToLower(); updRow.email = a.email; updRow.phone = a.phone; //envoi à la DAL try { DataProvider.UpdateAdministrateur(updRow); //si ok, renvoie true return(true); } catch (System.Data.SqlClient.SqlException e) { //si SQLException, log et renvoie false LogManager.LogSQLException(e.Message); return(false); } }
//Obtention de tous les administrateurs public static List <Administrateur> GetAll() { //Obtention de la dataTable OdawaDS.administrateursDataTable dt = DataProvider.GetAdministrateurs(); //Création d'une liste vide List <Administrateur> lst = new List <Administrateur>(); //Pour chaque administrateur dans la dataTable foreach (OdawaDS.administrateursRow adminRow in dt.Rows) { Administrateur a = new Administrateur(); a.id = adminRow.id; a.nom = adminRow.nom; a.prenom = adminRow.prenom; a.username = adminRow.username; a.password = adminRow.password; a.email = adminRow.email; a.phone = adminRow.phone; //Ajout à la liste lst.Add(a); } //retourne la liste return(lst); }