public async Task <ActionResult> MockDeposit(MockDepositModel model) { if (string.IsNullOrEmpty(model.Amount)) { return(this.JsonFailResult("#amount", Phrases.FieldShouldNotBeEmpty)); } double amount = 0; try { amount = model.Amount.ParseAnyDouble(); } catch (Exception) { return(this.JsonFailResult("#amount", Phrases.InvalidAmountFormat)); } var id = this.GetTraderId(); await _srvBalanceAccess.ChangeBalance(id, model.Currency, amount); await LkHub.RefreshBalance(id); return(this.JsonHideDialog()); }
private async Task ChangeBalance(IAssetPair assetPair, TraderOrderBase order, double exchangedVolume) { if (order.Action == OrderAction.Buy) { await _srvBalanceAccess.ChangeBalance(order.TraderId, assetPair.QuotingAssetId, order.Volume); await _srvBalanceAccess.ChangeBalance(order.TraderId, assetPair.BaseAssetId, -exchangedVolume); } else { await _srvBalanceAccess.ChangeBalance(order.TraderId, assetPair.QuotingAssetId, -order.Volume); await _srvBalanceAccess.ChangeBalance(order.TraderId, assetPair.BaseAssetId, exchangedVolume); } await UpdateBalanceChange(order.TraderId); }