コード例 #1
0
        public async Task UpdateDepositFeesSettings(DepositFees settings)
        {
            using var action = MyTelemetry.StartActivity("Update Deposit Fees Settings");
            settings.AddToActivityAsJsonTag("settings");
            try
            {
                _logger.LogInformation("Update Deposit Fees Setting: {jsonText}",
                                       JsonConvert.SerializeObject(settings));

                ValidateSettings(settings);

                var entity = DepositFeesNoSqlEntity.Create(settings);

                var existingItem = await _writer.GetAsync(entity.PartitionKey, entity.RowKey);

                if (existingItem == null)
                {
                    throw new Exception("Cannot update Deposit Fees Settings. Do not exist");
                }

                await _writer.InsertOrReplaceAsync(entity);

                _logger.LogInformation("Updated Deposit Fees Setting: {jsonText}",
                                       JsonConvert.SerializeObject(settings));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Cannot update ExternalMarketSettings: {requestJson}",
                                 JsonConvert.SerializeObject(settings));
                ex.FailActivity();
                throw;
            }
        }
コード例 #2
0
 public static DepositFeesNoSqlEntity Create(DepositFees depositFees)
 {
     return(new DepositFeesNoSqlEntity()
     {
         PartitionKey = GeneratePartitionKey(depositFees.BrokerId, depositFees.ProfileId),
         RowKey = GenerateRowKey(depositFees.AssetId),
         BrokerId = depositFees.BrokerId,
         AssetId = depositFees.AssetId,
         DepositFees = depositFees
     });
 }
コード例 #3
0
        public async Task <NullableValue <DepositFees> > GetDepositFees(GetDepositFeesRequest request)
        {
            try
            {
                var fees = _client.GetDepositFees(request.BrokerId, request.GroupId, request.AssetId);

                return(fees == null ? null : new NullableValue <DepositFees>(DepositFees.Create(fees)));
            }
            catch (Exception ex)
            {
                if (ex.Message == "Unknown HTTP result CodeNotFound. Message: Row not found")
                {
                    return(new NullableValue <DepositFees>());
                }
                throw;
            }
        }
コード例 #4
0
 private static void ValidateSettings(DepositFees settings)
 {
     if (string.IsNullOrEmpty(settings.BrokerId))
     {
         throw new Exception("Cannot add settings with empty broker");
     }
     if (string.IsNullOrEmpty(settings.ProfileId))
     {
         throw new Exception("Cannot add settings with empty profile");
     }
     if (string.IsNullOrEmpty(settings.AssetId))
     {
         throw new Exception("Cannot add settings with empty asset");
     }
     if (settings.FeeSizeRelative < 0 || settings.FeeSizeAbsolute < 0)
     {
         throw new Exception("Cannot add settings with negative fee size");
     }
 }