public void Leave(Character character)
        {
            //is it still valid? (not cancelled)
            if (!CorporationManager.IsInLeavePeriod(character))
            {
                Logger.Info("leaveCorporation: leave cancelled. characterID: " + character.Id);
                return;
            }

            if (character == CEO)
            {
                //ceo is leaving the corp, it's allowed only when he is the last one
                if (GetCharacterMembers().Count() > 1)
                {
                    Logger.Info("leaveCorporation: corporation has members leave cancelled for characterID:" + character.Id);
                    return;
                }

                //he is the last one = corp closing
                Logger.Info("leaveCorporation: corporation is closing: eid:" + Eid);
            }



            //freelancer corporation eid
            if (DefaultCorporation.IsFreelancerCorporation(Eid))
            {
                Logger.Info("leaveCorporation: character is in private corporation. characterID:" + character.Id);
                return;
            }

            var newCorporation = DefaultCorporation.GetFreelancerCorporation();

            newCorporation.AddMember(character, CorporationRole.NotDefined, this);

            RemoveMember(character);

            //remove from documents
            CorporationDocumentHelper.OnCorporationLeave(character, Eid);

            _channelManager.LeaveChannel(ChannelName, character);
            _channelManager.JoinChannel(newCorporation.ChannelName, character, CorporationRole.NotDefined);

            Transaction.Current.OnCommited(() =>
            {
                CorporationManager.InformCorporationMemberTransferred(this, newCorporation, character);

                character.GetPlayerRobotFromZone()?.UpdateCorporationOnZone(newCorporation.Eid);
                var info = new Dictionary <string, object>
                {
                    { k.from, Eid },
                    { k.to, newCorporation.Eid },
                    { k.characterID, character.Id },
                };

                ZoneManager.Value.Zones.ForEach(z => z.UpdateCorporation(CorporationCommand.TransferMember, info));
            });

            Logger.Info("characterID: " + character.Id + " left corporation: eid:" + Eid + " default corporation: eid:" + newCorporation.Eid);
        }
        public ErrorCodes Rent(Character character, bool useCorporationWallet)
        {
            //egyaltalan rentelheto?
            if (DocumentConfig.IsRentable)
            {
                if (_validUntil == null)
                {
                    return(ErrorCodes.ConsistencyError);
                }

                _validUntil = ((DateTime)_validUntil).AddDays(DocumentConfig.rentPeriodDays);

                ErrorCodes ec;
                if ((ec = UpdateValidUntil()) != ErrorCodes.NoError)
                {
                    return(ec);
                }

                CorporationDocumentHelper.CashInCreditForDocument(DocumentConfig.rentPrice, character, TransactionType.DocumentRent, useCorporationWallet);
                return(ErrorCodes.NoError);
            }


            return(ErrorCodes.InvalidDocumentType);
        }
        public ErrorCodes OnCreate(Character character, bool useCorporationWallet = false)
        {
            var ec = ErrorCodes.NoError;

            //itt minden mast is ellenorzunk

            if (maxPerCharacter > 0)
            {
                var amountByType = CorporationDocumentHelper.GetAmountByType(documentType, character);
                if (amountByType >= maxPerCharacter)
                {
                    return(ErrorCodes.NotEnoughDocumentSlots);
                }
            }

            if (creationPrice > 0)
            {
                CorporationDocumentHelper.CashInCreditForDocument(creationPrice, character, TransactionType.DocumentCreate, useCorporationWallet);
            }

            return(ec);
        }
 public IEnumerable <KeyValuePair <int, ReadWriteRole> > GetRegisteredMembers()
 {
     return(LazyInitializer.EnsureInitialized(ref _registeredMembers, () => CorporationDocumentHelper.GetRegistered(_id)));
 }