public async Task UpdateFeesSettings(FeesSettings settings) { using var action = MyTelemetry.StartActivity("Update Fees Settings Settings"); settings.AddToActivityAsJsonTag("settings"); try { _logger.LogInformation("Update Fees Settings Setting: {jsonText}", JsonConvert.SerializeObject(settings)); ValidateSettings(settings); var entity = FeesSettingsNoSqlEntity.Create(settings); var existingItem = await _writer.GetAsync(entity.PartitionKey, entity.RowKey); if (existingItem == null) { throw new Exception("Cannot update Fees Settings Settings. Do not exist"); } await _writer.InsertOrReplaceAsync(entity); _logger.LogInformation("Updated Fees Settings Setting: {jsonText}", JsonConvert.SerializeObject(settings)); } catch (Exception ex) { _logger.LogError(ex, "Cannot update ExternalMarketSettings: {requestJson}", JsonConvert.SerializeObject(settings)); ex.FailActivity(); throw; } }
public SettingsModel(FeesSettings settings) { Id = settings.Id; BrokerId = settings.BrokerId; FeeAccountId = settings.FeeAccountId; FeeWalletId = settings.FeeWalletId; Created = settings.Created.ToDateTime(); Modified = settings.Modified.ToDateTime(); }
public static FeesSettingsNoSqlEntity Create(FeesSettings feesSettings) { return(new FeesSettingsNoSqlEntity() { PartitionKey = GeneratePartitionKey(feesSettings.BrokerId), RowKey = GenerateRowKey(), BrokerId = feesSettings.BrokerId, FeesSettings = feesSettings }); }
private static void ValidateSettings(FeesSettings settings) { if (string.IsNullOrEmpty(settings.BrokerId)) { throw new Exception("Cannot add settings with empty broker"); } if (string.IsNullOrEmpty(settings.AccountId)) { throw new Exception("Cannot add settings with empty account"); } if (string.IsNullOrEmpty(settings.WalletId)) { throw new Exception("Cannot add settings with empty wallet"); } }
public override async Task <GetSettingsResponse> GetByBrokerId(GetSettingsByBrokerIdRequest request, ServerCallContext context) { var settings = await _settingsService.GetAsync(request.BrokerId); var result = new GetSettingsResponse(); if (settings == null) { return(result); } var feesSettings = new FeesSettings(); feesSettings.Id = settings.Id; feesSettings.BrokerId = settings.BrokerId; feesSettings.FeeAccountId = settings.FeeAccountId; feesSettings.FeeWalletId = settings.FeeWalletId; feesSettings.Created = settings.Created.ToTimestamp(); feesSettings.Modified = settings.Modified.ToTimestamp(); result.Settings = feesSettings; return(result); }