MvcWrench.Models.UserRepository.IsSvnAccountAvailable C# (CSharp) Method

IsSvnAccountAvailable() static private method

static private IsSvnAccountAvailable ( int userId, string account ) : bool
userId int
account string
return bool
        internal static bool IsSvnAccountAvailable(int userId, string account)
        {
            NpgsqlConnection conn = new NpgsqlConnection (conn_string);
            NpgsqlCommand comm = conn.CreateCommand ();

            // Add data to the User table
            string sql = "SELECT COUNT (*) FROM users WHERE id != @id AND svn = @svn";
            comm.CommandText = sql;

            comm.Parameters.Add ("@id", userId);
            comm.Parameters.Add ("@svn", account);

            conn.Open ();
            Int64 count = (Int64)comm.ExecuteScalar ();
            comm.Dispose ();

            return count == 0;
        }