push messages are sent upon user ids
This commit is contained in:
parent
783fda3e60
commit
44224e955f
10 changed files with 130 additions and 91 deletions
|
|
@ -108,7 +108,7 @@ namespace Yavsc.ApiControllers
|
|||
public async Task<IActionResult> ProSign(string billingCode, long id)
|
||||
{
|
||||
var estimate = dbContext.Estimates.
|
||||
Include(e=>e.Client).Include(e=>e.Client.DeviceDeclarations)
|
||||
Include(e=>e.Client).Include(e=>e.Client.DeviceDeclaration)
|
||||
.Include(e=>e.Bill).Include(e=>e.Owner).Include(e=>e.Owner.Performer)
|
||||
.FirstOrDefault(e=>e.Id == id);
|
||||
if (estimate == null)
|
||||
|
|
@ -127,12 +127,10 @@ namespace Yavsc.ApiControllers
|
|||
|
||||
var yaev = new EstimationEvent(estimate,_localizer);
|
||||
|
||||
var regids = estimate.Client.DeviceDeclarations.Select(d => d.DeviceId).ToArray();
|
||||
var regids = new [] { estimate.Client.Id };
|
||||
bool gcmSent = false;
|
||||
if (regids.Length>0) {
|
||||
var grep = await _GCMSender.NotifyEstimateAsync(regids,yaev);
|
||||
gcmSent = grep.success>0;
|
||||
}
|
||||
return Ok (new { ProviderValidationDate = estimate.ProviderValidationDate, GCMSent = gcmSent });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,19 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using System.Threading.Tasks;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.ViewModels.Chat;
|
||||
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Models;
|
||||
using ViewModels.Chat;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
[Route("api/chat")]
|
||||
public class ChatApiController : Controller
|
||||
{
|
||||
|
|
@ -25,30 +30,63 @@ namespace Yavsc.Controllers
|
|||
public IEnumerable<ChatUserInfo> GetUserList()
|
||||
{
|
||||
List<ChatUserInfo> result = new List<ChatUserInfo>();
|
||||
var cxsQuery = dbContext.ChatConnection?.Include(c=>c.Owner)
|
||||
.Where(cx => cx.Connected).GroupBy( c => c.ApplicationUserId );
|
||||
var cxsQuery = dbContext.ChatConnection?.Include(c => c.Owner)
|
||||
.Where(cx => cx.Connected).GroupBy(c => c.ApplicationUserId);
|
||||
|
||||
if (cxsQuery!=null)
|
||||
foreach (var g in cxsQuery) {
|
||||
if (cxsQuery != null)
|
||||
foreach (var g in cxsQuery)
|
||||
{
|
||||
|
||||
var uid = g.Key;
|
||||
var cxs = g.ToList();
|
||||
if (cxs !=null)
|
||||
if (cxs.Count>0) {
|
||||
var user = cxs.First().Owner;
|
||||
if (user!=null ) {
|
||||
result.Add(new ChatUserInfo { UserName = user.UserName,
|
||||
UserId = user.Id, Avatar = user.Avatar, Connections = cxs,
|
||||
Roles = ( userManager.GetRolesAsync(user) ).Result.ToArray() });
|
||||
var uid = g.Key;
|
||||
var cxs = g.ToList();
|
||||
if (cxs != null)
|
||||
if (cxs.Count > 0)
|
||||
{
|
||||
var user = cxs.First().Owner;
|
||||
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 });
|
||||
}
|
||||
}
|
||||
else {
|
||||
result.Add(new ChatUserInfo { Connections = cxs });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// GET: api/chat/userName
|
||||
[HttpGet("{userName}", Name = "uinfo")]
|
||||
public IActionResult GetUserInfo([FromRoute] string userName)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
// Miguel mech profiler
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
var user = dbContext.ApplicationUser.Include(u => u.Connections).FirstOrDefault(u => u.UserName == userName);
|
||||
|
||||
if (user == null) return HttpNotFound();
|
||||
|
||||
return Ok(new ChatUserInfo
|
||||
{
|
||||
UserName = user.UserName,
|
||||
UserId = user.Id,
|
||||
Avatar = user.Avatar,
|
||||
Connections = user.Connections,
|
||||
Roles = (userManager.GetRolesAsync(user)).Result.ToArray()
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue