public Task <bool> SetUserMediaItemDataAsync(Guid profileId, Guid mediaItemId, string key, string data)
        {
            ISQLDatabase database    = ServiceRegistration.Get <ISQLDatabase>();
            ITransaction transaction = database.BeginTransaction();

            try
            {
                bool result;
                using (IDbCommand command = UserProfileDataManagement_SubSchema.DeleteUserMediaItemDataCommand(transaction, profileId, mediaItemId, key))
                    command.ExecuteNonQuery();

                // Allow "delete only", if new data is null. This is used to delete no longer required data.
                if (!string.IsNullOrEmpty(data))
                {
                    using (IDbCommand command = UserProfileDataManagement_SubSchema.CreateUserMediaItemDataCommand(transaction, profileId, mediaItemId, key, data))
                        result = command.ExecuteNonQuery() > 0;
                }
                else
                {
                    result = true;
                }

                transaction.Commit();
                return(Task.FromResult(result));
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Error("UserProfileDataManagement: Error setting media item data '{0}' for media item '{1}' in profile '{2}'", e, key, mediaItemId, profileId);
                transaction.Rollback();
                throw;
            }
        }
        public bool SetUserMediaItemData(Guid profileId, Guid mediaItemId, string key, string data)
        {
            ISQLDatabase database    = ServiceRegistration.Get <ISQLDatabase>();
            ITransaction transaction = database.BeginTransaction();

            try
            {
                bool result;
                using (IDbCommand command = UserProfileDataManagement_SubSchema.DeleteUserMediaItemDataCommand(transaction, profileId, mediaItemId, key))
                    command.ExecuteNonQuery();
                using (IDbCommand command = UserProfileDataManagement_SubSchema.CreateUserMediaItemDataCommand(transaction, profileId, mediaItemId, key, data))
                    result = command.ExecuteNonQuery() > 0;
                transaction.Commit();
                return(result);
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Error("UserProfileDataManagement: Error setting media item data '{0}' for media item '{1}' in profile '{2}'", e, key, mediaItemId, profileId);
                transaction.Rollback();
                throw;
            }
        }