private async Task Handle(CrossClientCashoutStartedEvent evt, ICommandSender sender) { var aggregate = await _cashoutRepository.GetOrAddAsync( evt.OperationId, () => CrossClientCashoutAggregate.Start( evt.OperationId, evt.ClientId, evt.BlockchainType, evt.BlockchainAssetId, evt.HotWalletAddress, evt.ToAddress, evt.Amount, evt.AssetId, evt.RecipientClientId)); _chaosKitty.Meow(evt.OperationId); if (aggregate.State == CrossClientCashoutState.Started) { sender.SendCommand ( new EnrollToMatchingEngineCommand { CashinOperationId = aggregate.CashinOperationId, CashoutOperationId = aggregate.OperationId, RecipientClientId = aggregate.RecipientClientId, Amount = aggregate.Amount, AssetId = aggregate.AssetId }, CqrsModule.Self ); _chaosKitty.Meow(evt.OperationId); } }
public CrossClientCashoutAggregate ToDomain() { return(CrossClientCashoutAggregate.Restore( ETag, State, StartMoment, OperationId, ClientId, BlockchainType, BlockchainAssetId, HotWalletAddress, ToAddress, Amount, AssetId, MatchingEngineEnrollementMoment, RecipientClientId, CashinOperationId)); }
public static CrossClientCashoutEntity FromDomain(CrossClientCashoutAggregate aggregate) { return(new CrossClientCashoutEntity { ETag = string.IsNullOrEmpty(aggregate.Version) ? "*" : aggregate.Version, PartitionKey = GetPartitionKey(aggregate.OperationId), RowKey = GetRowKey(aggregate.OperationId), State = aggregate.State, StartMoment = aggregate.StartMoment, OperationId = aggregate.OperationId, ClientId = aggregate.ClientId, BlockchainType = aggregate.BlockchainType, BlockchainAssetId = aggregate.BlockchainAssetId, HotWalletAddress = aggregate.HotWalletAddress, ToAddress = aggregate.ToAddress, Amount = aggregate.Amount, AssetId = aggregate.AssetId, MatchingEngineEnrollementMoment = aggregate.MatchingEngineEnrollementMoment, RecipientClientId = aggregate.RecipientClientId, CashinOperationId = aggregate.CashinOperationId }); }
public async Task SaveAsync(CrossClientCashoutAggregate aggregate) { var entity = CrossClientCashoutEntity.FromDomain(aggregate); await _storage.ReplaceAsync(entity); }