コード例 #1
0
        public async Task SetIsInternalByWalletAsync(SetIsInternalByWalletRequest request)
        {
            using var activity = MyTelemetry.StartActivity("SetIsInternalByWalletAsync");
            request.AddToActivityAsJsonTag("request");

            _logger.LogWarning("Change IsInternal. Wallet: {walletId}, IsInternal: {flag}", request.WalletId, request.IsInternal);

            await using var ctx = new DatabaseContext(_dbContextOptionsBuilder.Options);

            var walletEntity = ctx.ClientWallet.FirstOrDefault(e => e.WalletId == request.WalletId);

            if (walletEntity != null)
            {
                if (request.IsInternal)
                {
                    walletEntity.EnableEarnProgram = false;
                }

                walletEntity.IsInternal = request.IsInternal;
                await ctx.SaveChangesAsync();
            }
        }
コード例 #2
0
        public async Task SetIsInternalByWalletAsync(SetIsInternalByWalletRequest request)
        {
            using var activity = MyTelemetry.StartActivity("SetIsInternalByWalletAsync");
            request.AddToActivityAsJsonTag("request");

            _logger.LogWarning("Change IsInternal. Wallet: {walletId}, IsInternal: {flag}", request.WalletId, request.IsInternal);

            await using var ctx = new DatabaseContext(_dbContextOptionsBuilder.Options);

            var walletEntity = ctx.ClientWallet.FirstOrDefault(e => e.WalletId == request.WalletId);

            if (walletEntity != null)
            {
                var oldWallet = (ClientWallet)walletEntity.Clone();

                if (request.IsInternal)
                {
                    walletEntity.EnableEarnProgram = false;
                }

                walletEntity.IsInternal = request.IsInternal;
                await ctx.SaveChangesAsync();

                await UpdateCache(
                    walletEntity.ClientId,
                    walletEntity.BrokerId,
                    new List <ClientWalletEntity> {
                    walletEntity
                });

                await _publisher.PublishAsync(new ClientWalletUpdateMessage()
                {
                    OldWallet = ClientWallet.Create(oldWallet),
                    NewWallet = ClientWallet.Create(walletEntity)
                });
            }
        }
コード例 #3
0
 public Task SetIsInternalByWalletAsync(SetIsInternalByWalletRequest request)
 {
     return(_grpcService.SetIsInternalByWalletAsync(request));
 }