public static User CreateUser(User user)
{
NpgsqlConnection conn = new NpgsqlConnection (conn_string);
NpgsqlCommand comm = conn.CreateCommand ();
// Add data to the User table
string sql = "INSERT INTO users (name, email) VALUES (@name, @email)";
comm.CommandText = sql;
comm.Parameters.Add ("@name", user.Name);
comm.Parameters.Add ("@email", user.Email);
conn.Open ();
comm.ExecuteNonQuery ();
comm.Dispose ();
User new_user = GetUser (user.Name);
// Add data to the OpenID table
comm = conn.CreateCommand ();
sql = "INSERT INTO openids (id, userid) VALUES (@id, @userid)";
comm.CommandText = sql;
comm.Parameters.Add ("@id", user.OpenID);
comm.Parameters.Add ("@userid", new_user.ID);
comm.ExecuteNonQuery ();
comm.Dispose ();
conn.Close ();
return new_user;
}