Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- listAccounts.Add(new Account { Username = "acc1", Password = "123", Roles = new String[] {"superadmin", "admin", "employee"} });
- listAccounts.Add(new Account { Username = "acc2", Password = "123", Roles = new String[] {"admin", "employee"} });
- listAccounts.Add(new Account { Username = "acc3", Password = "123", Roles = new String[] {"employee"} });
- public AccountModel() {
- DataTable dt_usuarios = new DataTable();
- DataTable dt_roles = new DataTable();
- String sql = "SELECT username,password FROM usuarios";
- conexion.conectar();
- MySqlDataAdapter datos = new MySqlDataAdapter(sql, conexion.con);
- datos.Fill(dt_usuarios);
- List<String> roles_list = new List<String>();
- foreach (DataRow user_name in dt_usuarios.Rows)
- {
- String sql_roles = "SELECT r.rol FROM roles r,userroles ur,usuarios u WHERE u.username='" + user_name[0].ToString() + "' AND u.id_usuarios=ur.id_usuarios AND ur.id_roles=r.id_roles";
- MySqlDataAdapter datos_roles = new MySqlDataAdapter(sql_roles, conexion.con);
- datos_roles.Fill(dt_roles);
- foreach (DataRow roles_user in dt_roles.Rows)
- {
- roles_list.Add(roles_user[0].ToString());
- }
- listAccounts.Add(new Account { Username = user_name[0].ToString(), Password = user_name[1].ToString(), Roles = new String[] { roles_list } });
- }
- conexion.cerrar();
- //listAccounts.Add(new Account { Username = "acc1", Password = "123", Roles = new String[] {"superadmin", "admin", "employee"} });
- //listAccounts.Add(new Account { Username = "acc2", Password = "123", Roles = new String[] {"admin", "employee"} });
- //listAccounts.Add(new Account { Username = "acc3", Password = "123", Roles = new String[] {"employee"} });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement