Beispiel #1
0
        public async Task SetEarnProgramByWalletAsync(SetEarnProgramByWalletRequest request)
        {
            using var activity = MyTelemetry.StartActivity("SetEarnProgramByWalletAsync");
            request.AddToActivityAsJsonTag("request");

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

            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();

                walletEntity.EnableEarnProgram = request.EnableEarnProgram;
                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)
                });
            }
        }
Beispiel #2
0
        public async Task SetEarnProgramByWalletAsync(SetEarnProgramByWalletRequest request)
        {
            using var activity = MyTelemetry.StartActivity("SetEarnProgramByWalletAsync");
            request.AddToActivityAsJsonTag("request");

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

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

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

            if (walletEntity != null)
            {
                walletEntity.EnableEarnProgram = request.EnableEarnProgram;
                await ctx.SaveChangesAsync();
            }
        }
 public Task SetEarnProgramByWalletAsync(SetEarnProgramByWalletRequest request)
 {
     return(_grpcService.SetEarnProgramByWalletAsync(request));
 }