public void InsuranceBuy(Character character, IEnumerable <long> robotEids)
        {
            //auto clean
            InsuranceHelper.CleanUpInsurances();

            var currentInsurances = InsuranceHelper.CountInsurances(character);
            var maxInsurances     = RealMaxSlotsPerCharacter(character);
            var insuranceDays     = GetInsuranceDays(character);

            Corporation usedCorporation = null;

            foreach (var robot in robotEids.Select(RobotHelper.LoadRobotOrThrow))
            {
                try
                {
                    InsuranceBuy(character, robot, ref currentInsurances, maxInsurances, insuranceDays, ref usedCorporation);
                }
                catch (PerpetuumException gex)
                {
                    character.SendItemErrorMessage(Commands.ProductionInsuranceBuy, gex.error, robot);
                }
            }

            usedCorporation?.SendInsuranceList();
        }
        public ErrorCodes InsuranceQuery(Character character, IEnumerable <long> targetEids, out Dictionary <string, object> result)
        {
            var ec = ErrorCodes.NoError;

            result = new Dictionary <string, object>();

            var corporationEid = character.CorporationEid;
            var insuranceDays  = GetInsuranceDays(character);

            var maxInsurances     = RealMaxSlotsPerCharacter(character);
            var currentInsurances = InsuranceHelper.CountInsurances(character);

            var counter = 0;

            foreach (var eid in targetEids)
            {
                var useCorporationWallet = false;
                var insurance            = _insuranceHelper.GetInsurance(eid);
                var endDate = DateTime.Now.AddDays(insuranceDays);

                var item = Item.GetOrThrow(eid);

                var robot = item as Robot;

                if (robot == null)
                {
                    ec = ErrorCodes.InsuranceAllowedForRobotsOnly;
                    continue;
                }

                if (!robot.IsSingleAndUnpacked)
                {
                    ec = ErrorCodes.RobotMustbeSingleAndNonRepacked;
                    continue;
                }

                double price, payOut;
                if ((ec = GetInsurancePrice(robot, out price, out payOut)) != ErrorCodes.NoError)
                {
                    continue;
                }

                var oneRobot = new Dictionary <string, object>
                {
                    { k.price, price },
                    { k.payOut, payOut },
                    { k.eid, robot.Eid },
                };

                if ((ec = _insuranceHelper.GetConditions(character, robot, insurance, corporationEid, insuranceDays, maxInsurances, currentInsurances, ref endDate, ref useCorporationWallet)) != ErrorCodes.NoError)
                {
                    continue;
                }

                oneRobot.Add(k.endTime, endDate); //ez lesz ha befizet ra

                if (insurance != null)
                {
                    oneRobot.Add(k.current, insurance.endDate); //ez a mostani, mert ez mar biztositva van
                }

                oneRobot.Add(k.useCorporationWallet, useCorporationWallet);

                result.Add("i" + counter++, (object)oneRobot);
            }

            if (targetEids.Count() == 1)
            {
                return(ec);
            }

            return(ErrorCodes.NoError);
        }