public AssetFees GetAssetFees(string brokerId, string groupId, string assetId, OperationType operationType) { var entity = _assetFeesReader.Get(AssetFeesNoSqlEntity.GeneratePartitionKey(brokerId, groupId), AssetFeesNoSqlEntity.GenerateRowKey(assetId, operationType)); if (entity == null) { return(new AssetFees { FeeType = FeeType.NoFee }); } var result = entity.AssetFees; if (string.IsNullOrEmpty(result.AccountId) || string.IsNullOrEmpty(result.WalletId)) { var settings = _feesSettingsReader.Get(FeesSettingsNoSqlEntity.GeneratePartitionKey(brokerId), FeesSettingsNoSqlEntity.GenerateRowKey()); if (settings != null) { result.BrokerId = settings.FeesSettings.BrokerId; result.AccountId = settings.FeesSettings.AccountId; result.WalletId = settings.FeesSettings.WalletId; } } return(entity?.AssetFees); }
public async Task RemoveAssetFeesSettings(RemoveAssetFeesRequest request) { using var action = MyTelemetry.StartActivity("Remove Asset Fees Settings"); request.AddToActivityAsJsonTag("request"); try { _logger.LogInformation("Remove Asset Fees Setting: {jsonText}", JsonConvert.SerializeObject(request)); var entity = await _writer.DeleteAsync(AssetFeesNoSqlEntity.GeneratePartitionKey(request.BrokerId, request.ProfileId), AssetFeesNoSqlEntity.GenerateRowKey(request.AssetId, request.OperationType)); if (entity != null) { _logger.LogInformation("Removed Asset Fees Settings: {jsonText}", JsonConvert.SerializeObject(entity)); } else { _logger.LogInformation("Unable to remove Asset Fees Setting, do not exist: {jsonText}", JsonConvert.SerializeObject(request)); } } catch (Exception ex) { _logger.LogError(ex, "Cannot remove ExternalMarketSettings: {requestJson}", JsonConvert.SerializeObject(request)); ex.FailActivity(); throw; } }