private async Task Handle(AccountBalanceChangeFailedEvent e, ICommandSender sender) { if (e.Source != OperationName) { return; } var executionInfo = await _executionInfoRepository.GetAsync <WithdrawalDepositData>(OperationName, e.OperationId); if (executionInfo == null) { return; } if (SwitchState(executionInfo.Data, WithdrawalState.UpdatingBalance, WithdrawalState.UnfreezingAmount)) { executionInfo.Data.FailReason = e.Reason; sender.SendCommand( new UnfreezeMarginOnFailWithdrawalCommand( e.OperationId), _contextNames.TradingEngine); _chaosKitty.Meow(e.OperationId); await _executionInfoRepository.SaveAsync(executionInfo); } }
private async Task Handle(AccountBalanceChangeFailedEvent e, ICommandSender sender) { if (e.Source != OperationName) { return; } var executionInfo = await _executionInfoRepository.GetAsync <GiveTemporaryCapitalData>(OperationName, e.OperationId); if (executionInfo == null) { return; } if (executionInfo.Data.SwitchState(TemporaryCapitalState.Started, TemporaryCapitalState.Failing)) { executionInfo.Data.FailReason = e.Reason; sender.SendCommand( new FinishGiveTemporaryCapitalInternalCommand( e.OperationId, _systemClock.UtcNow.UtcDateTime, false, e.Reason), _contextNames.AccountsManagement); _chaosKitty.Meow($"{nameof(AccountBalanceChangeFailedEvent)}: " + "Save_OperationExecutionInfo:" + e.OperationId); await _executionInfoRepository.SaveAsync(executionInfo); } }