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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue