no message
This commit is contained in:
parent
c1cfaa3b6d
commit
468bd38e0b
9 changed files with 247 additions and 166 deletions
|
|
@ -7,7 +7,9 @@ using BMA.EHR.Domain.Models.Notifications;
|
|||
using BMA.EHR.Domain.Shared;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories.MessageQueue
|
||||
|
|
@ -19,6 +21,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
private readonly IApplicationDBContext _dbContext;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly EmailSenderService _emailSenderService;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -26,11 +29,13 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
|
||||
public NotificationRepository(IApplicationDBContext dbContext,
|
||||
EmailSenderService emailSenderService,
|
||||
IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_emailSenderService = emailSenderService;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -50,8 +55,26 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
// // throw new Exception(GlobalMessages.DataNotFound);
|
||||
// }
|
||||
|
||||
var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position";
|
||||
var profileId = "";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||
|
||||
if (org == null || org.result == null)
|
||||
return new List<InboxResponse>();
|
||||
profileId = org.result.rootId == null ? "" : org.result.profileId;
|
||||
}
|
||||
if (profileId == null || profileId == "")
|
||||
return new List<InboxResponse>();
|
||||
|
||||
var data_search = await _dbContext.Set<Notification>()
|
||||
.Where(x => x.KeycloakUserId == UserId)
|
||||
.Where(x => x.ReceiverUserId == Guid.Parse(profileId))
|
||||
.Where(x => x.DeleteDate == null)
|
||||
.OrderByDescending(x => x.ReceiveDate)
|
||||
.ToListAsync();
|
||||
|
|
@ -107,9 +130,26 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
// {
|
||||
// return 0;
|
||||
// }
|
||||
var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position";
|
||||
var profileId = "";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||
|
||||
if (org == null || org.result == null)
|
||||
return 0;
|
||||
profileId = org.result.rootId == null ? "" : org.result.profileId;
|
||||
}
|
||||
if (profileId == null || profileId == "")
|
||||
return 0;
|
||||
|
||||
var data_search = await _dbContext.Set<Notification>()
|
||||
.Where(x => x.KeycloakUserId == UserId)
|
||||
.Where(x => x.ReceiverUserId == Guid.Parse(profileId))
|
||||
.Where(x => x.DeleteDate == null)
|
||||
.Where(x => x.IsOpen == false)
|
||||
.OrderByDescending(x => x.ReceiveDate)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue