แก้ env

This commit is contained in:
Kittapath 2024-07-09 17:03:54 +07:00
parent 41d28c4d7f
commit b37ca083ba
13 changed files with 633 additions and 65 deletions

View file

@ -85,27 +85,59 @@ namespace BMA.EHR.Placement.Service.Controllers
// if (profile == null)
// return Error(GlobalMessages.DataNotFound);
var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position";
using (var client = new HttpClient())
var apiUrl = $"{_configuration["API"]}/org/profile/keycloakid/position/" + req.ReceiverUserId;
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.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)
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.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)
{
await _repositoryNoti.PushNotificationAsync(
Guid.Parse(org.result.profileId),
req.Subject,
req.Body,
req.Payload,
req.IsSendInbox,
req.IsSendMail
);
}
return Success();
await _repositoryNoti.PushNotificationAsync(
Guid.Parse(org.result.id),
req.Subject,
req.Body,
req.Payload,
req.IsSendInbox,
req.IsSendMail
);
}
return Success();
}
return Success();
}
[HttpPost("profile")]
public async Task<ActionResult<ResponseObject>> UpdatePropertyByUserKeycloak([FromBody] NotiRequest req)
{
// var profile = await _context.Profiles.FirstOrDefaultAsync(x => x.KeycloakId == req.ReceiverUserId);
// if (profile == null)
// return Error(GlobalMessages.DataNotFound);
// var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/" + req.ReceiverUserId;
// using (var client = new HttpClient())
// {
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.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 (req.ReceiverUserId != null)
{
await _repositoryNoti.PushNotificationAsync(
Guid.Parse(req.ReceiverUserId),
req.Subject,
req.Body,
req.Payload,
req.IsSendInbox,
req.IsSendMail
);
}
return Success();
// }
return Success();
}
@ -117,28 +149,28 @@ namespace BMA.EHR.Placement.Service.Controllers
if (inbox == null)
return Error(GlobalMessages.DataNotFound);
var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position/{inbox.CreatedUserId}";
using (var client = new HttpClient())
var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position/{inbox.CreatedUserId}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.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)
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.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)
{
await _repositoryNoti.PushNotificationAsync(
Guid.Parse(org.result.id),
req.Subject,
req.Body,
req.Payload,
req.IsSendInbox,
req.IsSendMail
);
}
return Success();
await _repositoryNoti.PushNotificationAsync(
Guid.Parse(org.result.id),
req.Subject,
req.Body,
req.Payload,
req.IsSendInbox,
req.IsSendMail
);
}
return Success();
}
// var profile = await _context.Profiles.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(inbox.CreatedUserId));
// if (profile == null)
// return Error(GlobalMessages.DataNotFound);