.
This commit is contained in:
@ -23,13 +23,13 @@ namespace Yavsc.Controllers
|
||||
}
|
||||
|
||||
[HttpGet("users")]
|
||||
public async Task<List<ChatUserInfo>> GetUserList()
|
||||
public IEnumerable<ChatUserInfo> GetUserList()
|
||||
{
|
||||
|
||||
var cxsQuery = dbContext.Connections.Include(c=>c.Owner).GroupBy( c => c.ApplicationUserId );
|
||||
|
||||
List<ChatUserInfo> result = new List<ChatUserInfo>();
|
||||
var cxsQuery = dbContext.Connections?.Include(c=>c.Owner).GroupBy( c => c.ApplicationUserId );
|
||||
|
||||
// List<ChatUserInfo> result = new List<ChatUserInfo>();
|
||||
if (cxsQuery!=null)
|
||||
foreach (var g in cxsQuery) {
|
||||
|
||||
var uid = g.Key;
|
||||
@ -38,12 +38,12 @@ namespace Yavsc.Controllers
|
||||
if (cxs.Count>0) {
|
||||
var user = cxs.First().Owner;
|
||||
|
||||
result.Add(new ChatUserInfo { UserName = user.UserName,
|
||||
yield return new ChatUserInfo { UserName = user.UserName,
|
||||
UserId = user.Id, Avatar = user.Avatar, Connections = cxs,
|
||||
Roles = ( await userManager.GetRolesAsync(user) ).ToArray() } );
|
||||
Roles = ( userManager.GetRolesAsync(user) ).Result.ToArray() };
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,12 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
using Yavsc.Models;
|
||||
using YavscLib;
|
||||
|
||||
namespace Yavsc.Model.Chat
|
||||
{
|
||||
|
||||
public class Connection
|
||||
public class Connection : IConnection
|
||||
{
|
||||
[JsonIgnore]
|
||||
public string ApplicationUserId { get; set; }
|
||||
|
@ -15,7 +15,7 @@ namespace Yavsc
|
||||
app.UseWebSockets();
|
||||
|
||||
app.UseSignalR("/api/signalr");
|
||||
|
||||
/*
|
||||
var _sockets = new ConcurrentBag<WebSocket>();
|
||||
|
||||
app.Use(
|
||||
@ -56,7 +56,7 @@ namespace Yavsc
|
||||
await next();
|
||||
}
|
||||
}
|
||||
);
|
||||
); */
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ using System.Collections.Generic;
|
||||
using Yavsc.Model.Chat;
|
||||
|
||||
namespace Yavsc.ViewModels.Chat {
|
||||
public class ChatUserInfo
|
||||
public class ChatUserInfo : IChatUserInfo
|
||||
{
|
||||
|
||||
public List<Connection> Connections { get; set; }
|
||||
@ -16,4 +16,16 @@ public class ChatUserInfo
|
||||
public string[] Roles { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public interface IChatUserInfo
|
||||
{
|
||||
List<Connection> Connections { get; set; }
|
||||
string UserId { get; set; }
|
||||
|
||||
string UserName { get; set; }
|
||||
|
||||
string Avatar { get; set; }
|
||||
|
||||
string[] Roles { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,7 @@
|
||||
"System.Runtime": "4.0.0",
|
||||
"System.Globalization": "4.0.0",
|
||||
"System.Resources.ResourceManager": "4.0.0",
|
||||
"System.Resources.Reader": "4.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,7 @@
|
||||
".NETPortable,Version=v4.5,Profile=Profile111": [
|
||||
"fx/System.Runtime >= 4.0.0",
|
||||
"fx/System.Globalization >= 4.0.0",
|
||||
"fx/System.Resources.ResourceManager >= 4.0.0",
|
||||
"fx/System.Resources.Reader >= 4.0.0"
|
||||
"fx/System.Resources.ResourceManager >= 4.0.0"
|
||||
]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user