public async Task AddDeviceAsync(IAgentContext agentContext, AddDeviceInfoMessage message) { var connection = await GetMediatorConnectionAsync(agentContext); if (connection != null) { await messageService.SendAsync(agentContext.Wallet, message, connection); } }
private async Task AddDeviceInfoAsync(IAgentContext agentContext, ConnectionRecord connection, AddDeviceInfoMessage addDeviceInfoMessage) { var inboxId = connection.GetTag("InboxId"); if (inboxId == null) { throw new InvalidOperationException("Inbox was not found. Create an inbox first"); } var deviceRecord = new DeviceInfoRecord { InboxId = inboxId, DeviceId = addDeviceInfoMessage.DeviceId, DeviceVendor = addDeviceInfoMessage.DeviceVendor }; await recordService.AddAsync(agentContext.Wallet, deviceRecord); }
private async Task AddDeviceInfoAsync(IAgentContext agentContext, ConnectionRecord connection, AddDeviceInfoMessage addDeviceInfoMessage) { var inboxId = connection.GetTag("InboxId"); if (inboxId == null) { throw new InvalidOperationException("Inbox was not found. Create an inbox first"); } var deviceRecord = new DeviceInfoRecord { InboxId = inboxId, DeviceId = addDeviceInfoMessage.DeviceId, DeviceVendor = addDeviceInfoMessage.DeviceVendor }; try { await recordService.AddAsync(agentContext.Wallet, deviceRecord); } catch (WalletItemAlreadyExistsException) { } catch (Exception e) { logger.LogError(e, "Unable to register device", addDeviceInfoMessage); } }