Esempio n. 1
0
        public async Task RemoveDepositFeesSettings(RemoveDepositFeesRequest request)
        {
            using var action = MyTelemetry.StartActivity("Remove Deposit Fees Settings");
            request.AddToActivityAsJsonTag("request");
            try
            {
                _logger.LogInformation("Remove Deposit Fees Setting: {jsonText}",
                                       JsonConvert.SerializeObject(request));

                var entity = await _writer.DeleteAsync(DepositFeesNoSqlEntity.GeneratePartitionKey(request.BrokerId, request.ProfileId),
                                                       DepositFeesNoSqlEntity.GenerateRowKey(request.AssetId));

                if (entity != null)
                {
                    _logger.LogInformation("Removed Deposit Fees Settings: {jsonText}",
                                           JsonConvert.SerializeObject(entity));
                }
                else
                {
                    _logger.LogInformation("Unable to remove Deposit 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;
            }
        }
Esempio n. 2
0
        public DepositFees GetDepositFees(string brokerId, string groupId, string assetId)
        {
            var entity = _depositFeesReader.Get(DepositFeesNoSqlEntity.GeneratePartitionKey(brokerId, groupId),
                                                DepositFeesNoSqlEntity.GenerateRowKey(assetId));

            if (entity == null)
            {
                return(new DepositFees {
                    FeeType = FeeType.NoFee
                });
            }

            return(entity?.DepositFees);
        }
Esempio n. 3
0
        public async Task <OperationResponse> CreateDepositProfile(CreateGroupRequest request)
        {
            try
            {
                var groups = await _profileWriter.GetAsync(FeeProfilesNoSqlEntity.GeneratePartitionKey(),
                                                           FeeProfilesNoSqlEntity.GenerateRowKey());

                var withdrawalList = groups?.Profiles ?? new List <string>()
                {
                    FeeProfileConsts.DefaultProfile
                };
                var depositList = groups?.DepositProfiles ?? new List <string>();
                depositList.Add(request.ProfileId);
                await _profileWriter.InsertOrReplaceAsync(FeeProfilesNoSqlEntity.Create(withdrawalList, depositList.Distinct().ToList()));

                if (!string.IsNullOrWhiteSpace(request.CloneFromProfileId))
                {
                    var assets =
                        (await _depositWriter.GetAsync(
                             DepositFeesNoSqlEntity.GeneratePartitionKey(request.BrokerId, request.CloneFromProfileId)))
                        .Select(t => t.DepositFees).ToList();

                    foreach (var asset in assets)
                    {
                        asset.ProfileId = request.ProfileId;
                    }

                    await _depositWriter.BulkInsertOrReplaceAsync(assets.Select(DepositFeesNoSqlEntity.Create).ToList());
                }

                return(new OperationResponse()
                {
                    IsSuccess = true
                });
            }
            catch (Exception e)
            {
                return(new OperationResponse()
                {
                    IsSuccess = false,
                    ErrorText = e.Message
                });
            }
        }
Esempio n. 4
0
        public async Task <OperationResponse> DeleteDepositProfile(DeleteProfileRequest request)
        {
            try
            {
                var groups = await _profileWriter.GetAsync(FeeProfilesNoSqlEntity.GeneratePartitionKey(),
                                                           FeeProfilesNoSqlEntity.GenerateRowKey());

                var withdrawalList = groups?.Profiles ?? new List <string>()
                {
                    FeeProfileConsts.DefaultProfile
                };
                var depositList = groups?.DepositProfiles ?? new List <string>();

                var list = depositList.Distinct().ToList();
                list.Remove(request.ProfileId);
                await _profileWriter.InsertOrReplaceAsync(FeeProfilesNoSqlEntity.Create(withdrawalList, list));

                var assets =
                    (await _depositWriter.GetAsync(
                         DepositFeesNoSqlEntity.GeneratePartitionKey(request.BrokerId, request.ProfileId))).ToList();

                foreach (var asset in assets)
                {
                    await _depositWriter.DeleteAsync(asset.PartitionKey, asset.RowKey);
                }

                return(new OperationResponse()
                {
                    IsSuccess = true
                });
            }
            catch (Exception e)
            {
                return(new OperationResponse()
                {
                    IsSuccess = false,
                    ErrorText = e.Message
                });
            }
        }