public async Task <Guid> CreateProfileAsync(string profileName)
        {
            //Profile might already exist.
            var result = await GetProfileByNameAsync(profileName);

            if (result.Success)
            {
                return(result.Result.ProfileId);
            }

            ISQLDatabase database    = ServiceRegistration.Get <ISQLDatabase>();
            ITransaction transaction = database.BeginTransaction();
            Guid         profileId   = Guid.NewGuid();

            try
            {
                using (IDbCommand command = UserProfileDataManagement_SubSchema.CreateUserProfileCommand(transaction, profileId, profileName))
                    command.ExecuteNonQuery();
                transaction.Commit();
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Error("UserProfileDataManagement: Error creating user profile '{0}')", e, profileName);
                transaction.Rollback();
                throw;
            }
            return(profileId);
        }
        public Guid CreateProfile(string profileName)
        {
            //Profile might already exist.
            UserProfile existingProfile;

            if (GetProfileByName(profileName, out existingProfile))
            {
                return(existingProfile.ProfileId);
            }

            ISQLDatabase database    = ServiceRegistration.Get <ISQLDatabase>();
            ITransaction transaction = database.BeginTransaction();
            Guid         profileId   = Guid.NewGuid();

            try
            {
                using (IDbCommand command = UserProfileDataManagement_SubSchema.CreateUserProfileCommand(transaction, profileId, profileName))
                    command.ExecuteNonQuery();
                transaction.Commit();
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Error("UserProfileDataManagement: Error creating user profile '{0}')", e, profileName);
                transaction.Rollback();
                throw;
            }
            return(profileId);
        }
        private Guid CreateProfileInternal(Guid profileId, string profileName, UserProfileType profileType, string profilePassword)
        {
            ISQLDatabase database    = ServiceRegistration.Get <ISQLDatabase>();
            ITransaction transaction = database.BeginTransaction();

            try
            {
                using (IDbCommand command = UserProfileDataManagement_SubSchema.CreateUserProfileCommand(transaction, profileId, profileName, profileType, profilePassword))
                    command.ExecuteNonQuery();
                transaction.Commit();
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Error("UserProfileDataManagement: Error creating user profile '{0}')", e, profileName);
                transaction.Rollback();
                throw;
            }
            return(profileId);
        }