private void CheckExtensionLevelAndThrowIfFailed(Character character)
        {
            var liveSparkTeleports = _sparkTeleportHelper.GetAllSparkTeleports(character);
            var alreadySpent       = _sparkTeleportHelper.GetCostFromDescriptions(liveSparkTeleports);
            var maxCount           = _sparkTeleportHelper.GetMaxSparkTeleportCount(character);

            if (alreadySpent <= maxCount)
            {
                return; //
            }
            var gex = PerpetuumException.Create(ErrorCodes.SparkTeleportExtensionLevelTooLow);

            var extension = _extensionReader.GetExtensionByName(ExtensionNames.SPARK_TELEPORT_COUNT_BASIC);

            if (extension != null)
            {
                gex.SetData(k.extensionID, extension.id);
            }

            throw gex;
        }
        public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var character = request.Session.Character;
                character.IsDocked.ThrowIfFalse(ErrorCodes.CharacterHasToBeDocked);

                var dockingBase = character.GetCurrentDockingBase();
                dockingBase.IsDockingAllowed(character).ThrowIfError();
                if (dockingBase.Zone is TrainingZone)
                {
                    throw new PerpetuumException(ErrorCodes.TrainingCharacterInvolved);
                }

                var sparkTeleports = _sparkTeleportHelper.GetAllSparkTeleports(character).ToArray();
                if (sparkTeleports.Any(d => d.DockingBase == dockingBase))
                {
                    throw new PerpetuumException(ErrorCodes.BaseAlreadySparkTeleportDestination);
                }

                var alreadySpent = _sparkTeleportHelper.GetCostFromDescriptions(sparkTeleports);
                var maxCount     = _sparkTeleportHelper.GetMaxSparkTeleportCount(character);
                if (alreadySpent + dockingBase.Zone.Configuration.SparkCost > maxCount)
                {
                    throw new PerpetuumException(ErrorCodes.NotEnoughSparkTeleportSlots);
                }

                character.SubtractFromWallet(TransactionType.SparkTeleportPlace, SparkTeleport.SPARK_TELEPORT_PLACE_FEE);

                _sparkTeleportHelper.CreateSparkTeleport(dockingBase, character);

                Transaction.Current.OnCommited(() =>
                {
                    var info = _sparkTeleportHelper.GetSparkTeleportDescriptionInfos(character);
                    Message.Builder.FromRequest(request).WithData(info).Send();
                });

                scope.Complete();
            }
        }