fixe l'accès web au chat privé

This commit is contained in:
2016-11-03 14:52:17 +01:00
parent a6f4af29c2
commit 8a66b578a3
18 changed files with 2403 additions and 104 deletions

View File

@ -8,6 +8,10 @@ using Yavsc.ViewModels.Account;
using System.Security.Claims;
using Microsoft.Extensions.Logging;
using Yavsc.Models.Auth;
using System.Collections.Generic;
using static Yavsc.ChatHub;
using Microsoft.Data.Entity;
using System.Linq;
namespace Yavsc.WebApi.Controllers
{
@ -159,6 +163,8 @@ namespace Yavsc.WebApi.Controllers
}
return Ok();
}
}
}

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity;
namespace Yavsc.Controllers
{
using Models;
using ViewModels.Chat;
[Route("api/chat")]
public class ChatApiController : Controller
{
[HttpGet("users")]
public List<ChatUserInfo> GetUserList()
{
using (var db = new ApplicationDbContext()) {
var cxsQuery = db.Connections.Include(c=>c.Owner).GroupBy( c => c.ApplicationUserId );
List<ChatUserInfo> result = new List<ChatUserInfo>();
foreach (var g in cxsQuery) {
var uid = g.Key;
var cxs = g.ToList();
var user = cxs.First().Owner;
result.Add(new ChatUserInfo { UserName = user.UserName,
UserId = user.Id, Avatar = user.Avatar, Connections = cxs } );
}
return result;
}
}
}
}