public HeartbeatCashoutAggregate ToDomain()
 {
     return(HeartbeatCashoutAggregate.Restore(version: ETag,
                                              startMoment: StartMoment,
                                              operationFinishMoment: OperationFinishMoment,
                                              operationId: OperationId,
                                              amount: Amount, assetId: AssetId,
                                              toAddress: ToAddress,
                                              toAddressExtension: ToAddressExtension,
                                              currentState: CurrentState,
                                              lockAcquiredAt: LockAcquiredAt,
                                              lockRejectedAt: LockRejectedAt,
                                              lastMomentRegisteredAt: LastMomentRegisteredAt,
                                              maxCashoutInactivePeriod: MaxCashoutInactivePeriod,
                                              preconditionPassedAt: PreconditionPassedAt,
                                              preconditionRejectedAt: PreconditionRejectedAt,
                                              assetInfoRetrievedAt: AssetInfoRetrievedAt,
                                              assetAccuracy: AssetAccuracy,
                                              assetAddress: AssetAddress,
                                              assetBlockchain: AssetBlockchain,
                                              assetBlockchainIntegrationLayerId: AssetBlockchainIntegrationLayerId,
                                              assetMultiplierPower: AssetMultiplierPower,
                                              assetType: AssetType,
                                              assetBlockchainWithdrawal: AssetBlockchainWithdrawal,
                                              assetCashoutMinimalAmount: AssetCashoutMinimalAmount,
                                              assetDisplayId: AssetDisplayId,
                                              assetIsTradable: AssetIsTradable,
                                              assetIsTrusted: AssetIsTrusted,
                                              assetKycNeeded: AssetKycNeeded,
                                              assetLowVolumeAmount: AssetLowVolumeAmount,
                                              assetLykkeEntityId: AssetLykkeEntityId,
                                              clientId: ClientId,
                                              feeCashoutTargetClientId: FeeCashoutTargetClientId,
                                              clientBalance: ClientBalance));
 }
        private async Task Handle(HeartbeatCashoutStartedEvent evt, ICommandSender sender)
        {
            var aggregate = await _repository.GetOrAddAsync(
                evt.OperationId,
                () => HeartbeatCashoutAggregate.StartNew(evt.OperationId,
                                                         evt.ToAddress,
                                                         evt.ToAddressExtension,
                                                         evt.Amount,
                                                         evt.AssetId,
                                                         evt.MaxCashoutInactivePeriod,
                                                         evt.ClientId,
                                                         evt.FeeCashoutTargetClientId,
                                                         evt.ClientBalance));

            _chaosKitty.Meow(evt.OperationId);

            if (aggregate.OnStarted())
            {
                sender.SendCommand(new AcquireCashoutLockCommand
                {
                    OperationId = evt.OperationId,
                    AssetId     = evt.AssetId
                },
                                   HeartbeatCashoutBoundedContext.Name);

                _chaosKitty.Meow(evt.OperationId);

                await _repository.SaveAsync(aggregate);
            }
        }
 public static HeartbeatCashoutEntity FromDomain(HeartbeatCashoutAggregate aggregate)
 {
     return(new HeartbeatCashoutEntity
     {
         ETag = string.IsNullOrEmpty(aggregate.Version) ? "*" : aggregate.Version,
         PartitionKey = GetPartitionKey(aggregate.OperationId),
         RowKey = GetRowKey(aggregate.OperationId),
         StartMoment = aggregate.StartMoment,
         LockAcquiredAt = aggregate.LockAcquiredAt,
         LockRejectedAt = aggregate.LockRejectedAt,
         LastMomentRegisteredAt = aggregate.LastMomentRegisteredAt,
         PreconditionPassedAt = aggregate.PreconditionPassedAt,
         PreconditionRejectedAt = aggregate.PreconditionRejectedAt,
         AssetInfoRetrievedAt = aggregate.AssetInfoRetrievedAt,
         OperationFinishMoment = aggregate.OperationFinishMoment,
         OperationId = aggregate.OperationId,
         ToAddress = aggregate.ToAddress,
         ToAddressExtension = aggregate.ToAddressExtension,
         Amount = aggregate.Amount,
         AssetId = aggregate.AssetId,
         AssetDisplayId = aggregate.AssetDisplayId,
         AssetMultiplierPower = aggregate.AssetMultiplierPower,
         AssetAddress = aggregate.AssetAddress,
         AssetAccuracy = aggregate.AssetAccuracy,
         AssetBlockchain = aggregate.AssetBlockchain,
         AssetType = aggregate.AssetType,
         AssetIsTradable = aggregate.AssetIsTradable,
         AssetIsTrusted = aggregate.AssetIsTrusted,
         AssetKycNeeded = aggregate.AssetKycNeeded,
         AssetBlockchainIntegrationLayerId = aggregate.AssetBlockchainIntegrationLayerId,
         AssetCashoutMinimalAmount = aggregate.AssetCashoutMinimalAmount,
         AssetLowVolumeAmount = aggregate.AssetLowVolumeAmount,
         AssetBlockchainWithdrawal = aggregate.AssetBlockchainWithdrawal,
         AssetLykkeEntityId = aggregate.AssetLykkeEntityId,
         MaxCashoutInactivePeriod = aggregate.MaxCashoutInactivePeriod,
         CurrentState = aggregate.CurrentState,
         ClientId = aggregate.ClientId,
         ClientBalance = aggregate.ClientBalance,
         FeeCashoutTargetClientId = aggregate.FeeCashoutTargetClientId
     });
 }
 public Task SaveAsync(HeartbeatCashoutAggregate aggregate)
 {
     return(_aggregateRepository.SaveAsync(aggregate));
 }