|
@@ -1,5 +1,6 @@
|
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
using MTWorkHR.Application.Identity;
|
|
|
+using MTWorkHR.Application.Models;
|
|
|
using MTWorkHR.Core.Global;
|
|
|
using MTWorkHR.Core.UnitOfWork;
|
|
|
|
|
@@ -15,14 +16,14 @@ namespace MTWorkHR.API.Chat
|
|
|
}
|
|
|
public async Task getOnlineUsers()
|
|
|
{
|
|
|
- //var allConnections = await _unitOfWork.Connection.GetAllAsync();
|
|
|
- //var currUserId = allConnections.Item1.Where(c => c.SignalrId == Context.ConnectionId).Select(c => c.UserId).SingleOrDefault();
|
|
|
- //List<User> onlineUsers = allConnections
|
|
|
- // .Where(c => c.PersonId != currUserId)
|
|
|
- // .Select(c =>
|
|
|
- // new UserDto(c.PersonId, ctx.Person.Where(p => p.Id == c.PersonId).Select(p => p.Name).SingleOrDefault(), c.SignalrId)
|
|
|
- // ).ToList();
|
|
|
- //await Clients.Caller.SendAsync("getOnlineUsersResponse", onlineUsers);
|
|
|
+ var allConnections = await _unitOfWork.Connection.GetAllAsync();
|
|
|
+ var currUserId = allConnections.Item1.Where(c => c.SignalrId == Context.ConnectionId).Select(c => c.UserId).SingleOrDefault();
|
|
|
+ List<UserDto> onlineUsers = allConnections.Item1
|
|
|
+ .Where(c => c.UserId != currUserId)
|
|
|
+ .Select(c =>
|
|
|
+ new UserDto { Id = c.UserId, UserName = c.UserName /*, c.SignalrId*/ }
|
|
|
+ ).ToList();
|
|
|
+ await Clients.Caller.SendAsync("getOnlineUsersResponse", onlineUsers);
|
|
|
}
|
|
|
|
|
|
|