public async Task <ClientWalletList> GetWalletsByClient(JetClientIdentity clientId) { var entity = _reader.Get(ClientWalletNoSqlEntity.GeneratePartitionKey(clientId.BrokerId), ClientWalletNoSqlEntity.GenerateRowKey(clientId.ClientId)); if (entity != null) { return new ClientWalletList() { Wallets = entity.Wallets } } ; var wallets = await _grpcService.GetWalletsByClient(clientId); return(wallets); }
private async Task UpdateCache(string clientId, string brokerId, List <ClientWalletEntity> list) { if (string.IsNullOrWhiteSpace(brokerId) || string.IsNullOrWhiteSpace(clientId)) { throw new Exception($"Client and broker cannot be null. Client: {JsonConvert.SerializeObject(clientId)}"); } var noSqlEntity = new ClientWalletNoSqlEntity() { BrokerId = brokerId, ClientId = clientId, PartitionKey = ClientWalletNoSqlEntity.GeneratePartitionKey(brokerId), RowKey = ClientWalletNoSqlEntity.GenerateRowKey(clientId), Wallets = list.Select(e => new ClientWallet() { Name = e.Name, IsDefault = e.IsDefault, WalletId = e.WalletId, CreatedAt = e.CreatedAt, BaseAsset = e.BaseAsset, EnableUseTestNet = e.EnableUseTestNet, IsInternal = e.IsInternal, EnableEarnProgram = e.EnableEarnProgram }).ToList() }; try { await _writer.InsertOrReplaceAsync(noSqlEntity); } catch (Exception ex) { _logger.LogError(ex, "Cannot update cache. Entity: {json}", JsonConvert.SerializeObject(noSqlEntity)); } }