diff --git a/Yavsc/ApiControllers/ChatApiController.cs b/Yavsc/ApiControllers/ChatApiController.cs index f65590cd..b1337caa 100644 --- a/Yavsc/ApiControllers/ChatApiController.cs +++ b/Yavsc/ApiControllers/ChatApiController.cs @@ -23,13 +23,13 @@ namespace Yavsc.Controllers } [HttpGet("users")] - public async Task> GetUserList() + public IEnumerable GetUserList() { - var cxsQuery = dbContext.Connections.Include(c=>c.Owner).GroupBy( c => c.ApplicationUserId ); - - List result = new List(); + var cxsQuery = dbContext.Connections?.Include(c=>c.Owner).GroupBy( c => c.ApplicationUserId ); + // List result = new List(); + 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; + } } } diff --git a/Yavsc/Models/Chat/Connection.cs b/Yavsc/Models/Chat/Connection.cs index dcfb8c55..f9296737 100644 --- a/Yavsc/Models/Chat/Connection.cs +++ b/Yavsc/Models/Chat/Connection.cs @@ -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; } diff --git a/Yavsc/Startup/Startup.WebSockets.cs b/Yavsc/Startup/Startup.WebSockets.cs index fa2836e5..dc3935f6 100644 --- a/Yavsc/Startup/Startup.WebSockets.cs +++ b/Yavsc/Startup/Startup.WebSockets.cs @@ -15,7 +15,7 @@ namespace Yavsc app.UseWebSockets(); app.UseSignalR("/api/signalr"); - +/* var _sockets = new ConcurrentBag(); app.Use( @@ -56,7 +56,7 @@ namespace Yavsc await next(); } } - ); + ); */ } } } \ No newline at end of file diff --git a/Yavsc/ViewModels/Chat/ChatUserInfo.cs b/Yavsc/ViewModels/Chat/ChatUserInfo.cs index c7263152..e58b3e67 100644 --- a/Yavsc/ViewModels/Chat/ChatUserInfo.cs +++ b/Yavsc/ViewModels/Chat/ChatUserInfo.cs @@ -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 Connections { get; set; } @@ -16,4 +16,16 @@ public class ChatUserInfo public string[] Roles { get; set; } } + + public interface IChatUserInfo + { + List Connections { get; set; } + string UserId { get; set; } + + string UserName { get; set; } + + string Avatar { get; set; } + + string[] Roles { get; set; } + } } diff --git a/YavscLib/project.json b/YavscLib/project.json index 7700f259..69d4aa48 100644 --- a/YavscLib/project.json +++ b/YavscLib/project.json @@ -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" } } } -} \ No newline at end of file +} diff --git a/YavscLib/project.lock.json b/YavscLib/project.lock.json index 29807b00..ecd73a7b 100644 --- a/YavscLib/project.lock.json +++ b/YavscLib/project.lock.json @@ -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" ] } } \ No newline at end of file