un positionnement de paramètre workflow des pros

This commit is contained in:
Paul Schneider 2017-01-13 16:31:40 +01:00
commit 96746fcc0b
322 changed files with 25893 additions and 3844 deletions

View file

@ -6,33 +6,47 @@ using Microsoft.Data.Entity;
namespace Yavsc.Controllers
{
using Microsoft.AspNet.Identity;
using Models;
using ViewModels.Chat;
[Route("api/chat")]
public class ChatApiController : Controller
{
ApplicationDbContext dbContext;
UserManager<ApplicationUser> userManager;
public ChatApiController(ApplicationDbContext dbContext,
UserManager<ApplicationUser> userManager)
{
this.dbContext = dbContext;
this.userManager = userManager;
}
[HttpGet("users")]
public List<ChatUserInfo> GetUserList()
public IEnumerable<ChatUserInfo> GetUserList()
{
using (var db = new ApplicationDbContext()) {
List<ChatUserInfo> result = new List<ChatUserInfo>();
var cxsQuery = dbContext.Connections?.Include(c=>c.Owner).GroupBy( c => c.ApplicationUserId );
var cxsQuery = db.Connections.Include(c=>c.Owner).GroupBy( c => c.ApplicationUserId );
// List<ChatUserInfo> result = new List<ChatUserInfo>();
if (cxsQuery!=null)
foreach (var g in cxsQuery) {
List<ChatUserInfo> result = new List<ChatUserInfo>();
foreach (var g in cxsQuery) {
var uid = g.Key;
var cxs = g.ToList();
var uid = g.Key;
var cxs = g.ToList();
if (cxs !=null)
if (cxs.Count>0) {
var user = cxs.First().Owner;
result.Add(new ChatUserInfo { UserName = user.UserName,
UserId = user.Id, Avatar = user.Avatar, Connections = cxs } );
}
return result;
if (user!=null ) {
result.Add(new ChatUserInfo { UserName = user.UserName,
UserId = user.Id, Avatar = user.Avatar, Connections = cxs,
Roles = ( userManager.GetRolesAsync(user) ).Result.ToArray() });
}
else {
result.Add(new ChatUserInfo { Connections = cxs });
}
}
}
return result;
}
}
}