public async Task <IActionResult> GetAllUsersOnlineAsync() { var users = await _userRepo.GetAllAsync(); var result = new List <object>(); foreach (var user in users) { var connections = _connectionMapping.GetConnectionsByKey(user.Email); if (connections.Any()) { result.Add(new { user = new { id = user.Id, firstName = user.FirstName, lastName = user.LastName, email = user.Email, connectionIds = connections.ToArray() } }); } } return(Ok(result)); }