noti report

This commit is contained in:
kittapath 2024-10-07 23:23:00 +07:00
parent 85d9754db6
commit 037435b3bc
5 changed files with 83 additions and 26 deletions

View file

@ -62,10 +62,6 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost()]
public async Task<ActionResult<ResponseObject>> UpdatePropertyByUser([FromBody] NotiRequest req)
{
// var profile = await _context.Profiles.FirstOrDefaultAsync(x => x.Id == req.ReceiverUserId);
// if (profile == null)
// return Error(GlobalMessages.DataNotFound);
await _repositoryNoti.PushNotificationAsync(
Guid.Parse(req.ReceiverUserId),
req.Subject,
@ -81,10 +77,6 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost("keycloak")]
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/keycloakid/position/" + req.ReceiverUserId;
using (var client = new HttpClient())
{
@ -112,18 +104,6 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost("profile")]
public async Task<ActionResult<ResponseObject>> UpdatePropertyByUserProfile([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(
@ -136,7 +116,20 @@ namespace BMA.EHR.Placement.Service.Controllers
);
}
return Success();
// }
}
[HttpPost("profiles")]
public async Task<ActionResult<ResponseObject>> UpdatePropertyByUserProfiles([FromBody] NotisRequest req)
{
await _repositoryNoti.PushNotificationsAsync(
req.ReceiverUserIds.Select(x => Guid.Parse(x)).ToArray(),
req.Subject,
req.Body,
req.Payload,
req.IsSendInbox,
req.IsSendMail
);
return Success();
}
[HttpPut("{id:length(36)}")]
@ -170,11 +163,6 @@ namespace BMA.EHR.Placement.Service.Controllers
}
return Success();
}
// var profile = await _context.Profiles.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(inbox.CreatedUserId));
// if (profile == null)
// return Error(GlobalMessages.DataNotFound);
return Success();
}
[HttpPost("cronjob")]