public static CashoutEntity FromDomain(CashoutAggregate aggregate) { return(new CashoutEntity { ETag = string.IsNullOrEmpty(aggregate.Version) ? "*" : aggregate.Version, PartitionKey = GetPartitionKey(aggregate.OperationId), RowKey = GetRowKey(aggregate.OperationId), State = aggregate.State, Result = aggregate.Result, StartMoment = aggregate.StartMoment, OperationFinishMoment = aggregate.OperationFinishMoment, OperationId = aggregate.OperationId, ClientId = aggregate.ClientId, BlockchainType = aggregate.BlockchainType, BlockchainAssetId = aggregate.BlockchainAssetId, HotWalletAddress = aggregate.HotWalletAddress, ToAddress = aggregate.ToAddress, Amount = aggregate.Amount, AssetId = aggregate.AssetId, TransactionHash = aggregate.TransactionHash, TransactionAmount = aggregate.TransactionAmount, Fee = aggregate.Fee, Error = aggregate.Error, BatchId = aggregate.BatchId }); }
private async Task Handle(CashoutStartedEvent evt, ICommandSender sender) { var aggregate = await _cashoutRepository.GetOrAddAsync ( evt.OperationId, () => CashoutAggregate.Start ( evt.OperationId, evt.ClientId, evt.BlockchainType, evt.BlockchainAssetId, evt.HotWalletAddress, evt.ToAddress, evt.Amount, evt.AssetId ) ); _chaosKitty.Meow(evt.OperationId); if (aggregate.State == CashoutState.Started) { // TODO: Add tag (cashin/cashiout) to the operation, and pass it to the operations executor? sender.SendCommand ( new BlockchainOperationsExecutor.Contract.Commands.StartOperationExecutionCommand { OperationId = aggregate.OperationId, FromAddress = aggregate.HotWalletAddress, ToAddress = aggregate.ToAddress, AssetId = aggregate.AssetId, Amount = aggregate.Amount, // For the cashout all amount should be transfered to the destination address, // so the fee shouldn't be included in the amount. IncludeFee = false }, BlockchainOperationsExecutorBoundedContext.Name ); } }
public CashoutAggregate ToDomain() { return(CashoutAggregate.Restore( ETag, State, Result, StartMoment, OperationFinishMoment, OperationId, ClientId, BlockchainType, BlockchainAssetId, HotWalletAddress, ToAddress, Amount, AssetId, TransactionHash, TransactionAmount, Fee, Error, BatchId)); }
public async Task SaveAsync(CashoutAggregate aggregate) { var entity = CashoutEntity.FromDomain(aggregate); await _storage.ReplaceAsync(entity); }