public async Task Handle(INetConnection connection, PostClientInfoRequest command) { var clientInfo = await _dbContext.ClientInfos.FirstOrDefaultAsync(x => x.MacAddress == command.ClientInfo.MacAddress); if (clientInfo == null) { clientInfo = new ClientInfo() { MacAddress = command.ClientInfo.MacAddress }; _dbContext.ClientInfos.Add(clientInfo); } else { _dbContext.Entry(clientInfo).State = EntityState.Modified; } clientInfo.Ip = connection.GetIpAddress(); clientInfo.Username = command.ClientInfo.Username; clientInfo.OperationSystem = command.ClientInfo.OperationSystem; clientInfo.ComputerName = command.ClientInfo.ComputerName; clientInfo.LastOnlineAt = DateTime.UtcNow; await _dbContext.SaveChangesAsync(); }