예제 #1
0
        public IEnumerable <Accountlayout> GetAllUsers()
        {
            List <Accountlayout> allAccounts = new List <Accountlayout>();

            using (SqlCommand query = new SqlCommand("SELECT * FROM Logingegevens", _connection))
            {
                _connection.Open();
                try
                {
                    using (SqlDataReader reader = query.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var account = new Accountlayout();
                            account.Id             = Convert.ToInt32(reader["Id"]);
                            account.Gebruikersnaam = reader["Gebruikersnaam"].ToString();
                            account.Wachtwoord     = reader["Wachtwoord"].ToString();
                            //account.Wachtwoord = (byte[])reader["Wachtwoord"];
                            account.Email   = reader["Email"].ToString();
                            account.Created = Convert.ToDateTime(reader["Created"]);
                            account.Rol     = reader["Rol"].ToString();
                            allAccounts.Add(account);
                        }
                        reader.Close();
                    }
                }
                catch
                {
                    return(null);
                }

                _connection.Close();
                return(allAccounts);
            }
        }
예제 #2
0
 public IEnumerable <Accountlayout> GetAllUsers(string username)
 {
     using (SqlCommand query = new SqlCommand("SELECT * FROM Logingegevens", _connection))
     {
         List <Accountlayout> alleUsers = new List <Accountlayout>();
         _connection.Open();
         try
         {
             using (SqlDataReader reader = query.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     string Username = null;
                     var    account  = new Accountlayout
                     {
                         Id             = Convert.ToInt32(reader["Id"]),
                         Gebruikersnaam = reader["Gebruikersnaam"].ToString(),
                         Wachtwoord     = reader["Wachtwoord"].ToString(),
                         Email          = reader["Email"].ToString(),
                         Created        = Convert.ToDateTime(reader["Created"]),
                         Rol            = reader["Rol"].ToString()
                     };
                     Username = reader["Gebruikersnaam"].ToString();
                     if (Username != username)
                     {
                         alleUsers.Add(account);
                     }
                 }
                 reader.Close();
             }
         }
         catch
         {
             return(null);
         }
         _connection.Close();
         return(alleUsers);
     }
 }