noti probation
This commit is contained in:
parent
ffac27ef76
commit
3a334387bd
20 changed files with 33093 additions and 91 deletions
|
|
@ -1,9 +1,11 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Domain.Models.Notifications;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Domain.Models.Probation;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using BMA.EHR.Placement.Service.Requests;
|
||||
|
|
@ -28,13 +30,16 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private readonly ApplicationDBContext _context;
|
||||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
|
||||
public NotifyController(PlacementRepository repository,
|
||||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
NotificationRepository repositoryNoti,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_repository = repository;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
|
|
@ -55,54 +60,42 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound);
|
||||
|
||||
if (req.IsSendNotification == true)
|
||||
await _repositoryNoti.PushNotificationAsync(
|
||||
req.ReceiverUserId,
|
||||
req.Subject,
|
||||
req.Body,
|
||||
req.Payload,
|
||||
req.IsSendInbox,
|
||||
req.IsSendMail
|
||||
);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
[HttpPost("cronjob")]
|
||||
public async Task<ActionResult<ResponseObject>> CornjobProbation([FromBody] NotiCronjobProbationRequest req)
|
||||
{
|
||||
var profile = await _context.Profiles.FirstOrDefaultAsync(x => x.Id == req.ReceiverUserId);
|
||||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound);
|
||||
|
||||
_context.CronjobNotiProbations.Add(new CronjobNotiProbation
|
||||
{
|
||||
_context.Notifications.Add(new Notification
|
||||
{
|
||||
Body = req.Body,
|
||||
ReceiverUserId = req.ReceiverUserId,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
CreatedUserId = UserId ?? "System Administrator",
|
||||
CreatedFullName = FullName ?? "",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
});
|
||||
}
|
||||
if (req.IsSendInbox == true)
|
||||
{
|
||||
_context.Inboxes.Add(new Inbox
|
||||
{
|
||||
Subject = req.Subject,
|
||||
Body = req.Body,
|
||||
ReceiverUserId = req.ReceiverUserId,
|
||||
Payload = "",
|
||||
CreatedUserId = UserId ?? "System Administrator",
|
||||
CreatedFullName = FullName ?? "",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
});
|
||||
}
|
||||
if (req.IsSendMail == true)
|
||||
{
|
||||
// _context.Notifications.Add(new Notification
|
||||
// {
|
||||
// Body = req.Body,
|
||||
// ReceiverUserId = req.ReceiverUserId,
|
||||
// Type = "",
|
||||
// Payload = "",
|
||||
// CreatedUserId = UserId ?? "System Administrator",
|
||||
// CreatedFullName = FullName ?? "",
|
||||
// CreatedAt = DateTime.Now,
|
||||
// LastUpdateFullName = FullName ?? "System Administrator",
|
||||
// LastUpdateUserId = UserId ?? "",
|
||||
// LastUpdatedAt = DateTime.Now,
|
||||
// });
|
||||
}
|
||||
IsSendNoti = false,
|
||||
Subject = req.Subject,
|
||||
Body = req.Body,
|
||||
ReceiverUserId = req.ReceiverUserId,
|
||||
Payload = req.Payload,
|
||||
IsSendMail = req.IsSendMail,
|
||||
IsSendInbox = req.IsSendInbox,
|
||||
ReceiveDate = req.ReceiveDate,
|
||||
CreatedUserId = UserId ?? "System Administrator",
|
||||
CreatedFullName = FullName ?? "",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
|
|
|
|||
|
|
@ -373,7 +373,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
}
|
||||
}
|
||||
await _repositoryNoti.PushNotificationAsync(
|
||||
Guid.Parse("08db721d-ade4-480e-8d84-0853946a0ea5"),
|
||||
Guid.Parse("08db721d-add6-47b0-8a13-5f45d106e8d1"),
|
||||
$"{profile.Prefix?.Name}{profile.FirstName} {profile.LastName} ได้ทำการยื่นคำขอโอน",
|
||||
$"{profile.Prefix?.Name}{profile.FirstName} {profile.LastName} ได้ทำการยื่นคำขอโอนไปยัง {req.Organization}"
|
||||
);
|
||||
|
|
@ -427,6 +427,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> AdminConfirm(Guid id)
|
||||
{
|
||||
var uppdated = await _context.PlacementTransfers
|
||||
.Include(x => x.Profile)
|
||||
.ThenInclude(x => x.Prefix)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (uppdated == null)
|
||||
return Error(GlobalMessages.PlacementTransferNotFound, 404);
|
||||
|
|
@ -435,6 +437,16 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
uppdated.LastUpdateUserId = UserId ?? "";
|
||||
uppdated.LastUpdatedAt = DateTime.Now;
|
||||
await _repositoryNoti.PushNotificationAsync(
|
||||
Guid.Parse("08db721d-ade4-480e-8d84-0853946a0ea5"),
|
||||
$"{uppdated.Profile.Prefix?.Name}{uppdated.Profile.FirstName} {uppdated.Profile.LastName} ได้ทำการยื่นคำขอโอนได้รับการอนุมัติ",
|
||||
$"{uppdated.Profile.Prefix?.Name}{uppdated.Profile.FirstName} {uppdated.Profile.LastName} ได้ทำการยื่นคำขอโอนไปยัง {uppdated.Organization}ได้รับการอนุมัติ"
|
||||
);
|
||||
await _repositoryNoti.PushNotificationAsync(
|
||||
Guid.Parse("08db721d-ada0-4e64-89d3-7584a893d8b8"),
|
||||
$"{uppdated.Profile.Prefix?.Name}{uppdated.Profile.FirstName} {uppdated.Profile.LastName} ได้ทำการยื่นคำขอโอน",
|
||||
$"{uppdated.Profile.Prefix?.Name}{uppdated.Profile.FirstName} {uppdated.Profile.LastName} ได้ทำการยื่นคำขอโอนไปยัง {uppdated.Organization}ได้รับการอนุมัติ"
|
||||
);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue