private bool SwitchState(CashoutRiskControlState expectedState, CashoutRiskControlState nextState)
        {
            if (State < expectedState)
            {
                // Throws to retry and wait until aggregate will be in the required state
                throw new InvalidAggregateStateException(State, expectedState, nextState);
            }

            if (State > expectedState)
            {
                // Aggregate already in the next state, so this event can be just ignored
                return(false);
            }

            State = nextState;

            return(true);
        }
        private CashoutRiskControlAggregate(
            string version,
            CashoutRiskControlState state,
            CashoutRiskControlResult result,
            DateTime creationMoment,
            DateTime?startMoment,
            DateTime?operationAcceptanceMoment,
            DateTime?operationRejectionMoment,
            Guid operationId,
            Guid clientId,
            string assetId,
            string blockchainType,
            string blockchainAssetId,
            string hotWalletAddress,
            string toAddress,
            decimal amount,
            string error)
        {
            Version = version;
            State   = state;
            Result  = result;

            CreationMoment            = creationMoment;
            StartMoment               = startMoment;
            OperationAcceptanceMoment = operationAcceptanceMoment;
            OperationRejectionMoment  = operationRejectionMoment;

            OperationId       = operationId;
            ClientId          = clientId;
            AssetId           = assetId;
            BlockchainType    = blockchainType;
            BlockchainAssetId = blockchainAssetId;
            HotWalletAddress  = hotWalletAddress;
            ToAddress         = toAddress;
            Amount            = amount;

            Error = error;
        }
 public static CashoutRiskControlAggregate Restore(
     string version,
     CashoutRiskControlState state,
     CashoutRiskControlResult result,
     DateTime creationMoment,
     DateTime?startMoment,
     DateTime?operationAcceptanceMoment,
     DateTime?operationRejectionMoment,
     Guid operationId,
     Guid clientId,
     string assetId,
     string blockchainType,
     string blockchainAssetId,
     string hotWalletAddress,
     string toAddress,
     decimal amount,
     string error)
 {
     return(new CashoutRiskControlAggregate(
                version,
                state,
                result,
                creationMoment,
                startMoment,
                operationAcceptanceMoment,
                operationRejectionMoment,
                operationId,
                clientId,
                assetId,
                blockchainType,
                blockchainAssetId,
                hotWalletAddress,
                toAddress,
                amount,
                error));
 }