public void CreateUser(User user) { if (!DoesUsernameExist(user.Username)) { using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); var salt = EncryptionHandler.GenerateSalt(); using (SqlCommand cmd = new SqlCommand(repo.Create(), conn)) { cmd.Parameters.AddWithValue("@name", user.Name); cmd.Parameters.AddWithValue("@groupId", (int)user.GroupId); cmd.Parameters.AddWithValue("@username", user.Username); cmd.Parameters.AddWithValue("@password", EncryptionHandler.EncryptPassword(user.Password, salt)); cmd.Parameters.AddWithValue("@salt", salt); cmd.ExecuteNonQuery(); } } } else { Console.WriteLine("Username already exists"); } }