public static EthereumCashinAggregate Restore(
     string version,
     EthereumCashinState state,
     string transactionHash,
     Guid clientId,
     string assetId,
     string clientAddress,
     decimal amount,
     bool createPendingActions,
     Guid cashinOperationId,
     DateTime?cashinEnrolledToMatchingEngineDate,
     DateTime?historySavedDate)
 {
     return(new EthereumCashinAggregate(version,
                                        state,
                                        transactionHash,
                                        clientId,
                                        assetId,
                                        clientAddress,
                                        amount,
                                        createPendingActions,
                                        cashinOperationId,
                                        cashinEnrolledToMatchingEngineDate,
                                        historySavedDate));
 }
        private bool SwitchState(EthereumCashinState expectedState, EthereumCashinState 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 EthereumCashinAggregate(string version,
                                 EthereumCashinState state,
                                 string transactionHash,
                                 Guid clientId,
                                 string assetId,
                                 string clientAddress,
                                 decimal amount,
                                 bool createPendingActions,
                                 Guid cashinOperationId,
                                 DateTime?cashinEnrolledToMatchingEngineDate,
                                 DateTime?historySavedDate)
 {
     Version              = version;
     State                = state;
     TransactionHash      = transactionHash;
     ClientId             = clientId;
     AssetId              = assetId;
     ClientAddress        = clientAddress;
     Amount               = amount;
     CreatePendingActions = createPendingActions;
     CashinOperationId    = cashinOperationId;
     CashinEnrolledToMatchingEngineDate = cashinEnrolledToMatchingEngineDate;
     HistorySavedDate = historySavedDate;
 }