noti พ้นราชการ บรรจุ
This commit is contained in:
parent
e5af4a3513
commit
d34f04ffee
25 changed files with 16558 additions and 130 deletions
|
|
@ -1,4 +1,5 @@
|
|||
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;
|
||||
|
|
@ -24,16 +25,19 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
public class RetirementResignController : BaseController
|
||||
{
|
||||
private readonly RetirementRepository _repository;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public RetirementResignController(RetirementRepository repository,
|
||||
NotificationRepository repositoryNoti,
|
||||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_repository = repository;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
|
|
@ -293,6 +297,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
.Include(x => x.PosNo)
|
||||
.Include(x => x.Salaries)
|
||||
.Include(x => x.Position)
|
||||
.Include(x => x.Prefix)
|
||||
.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId));
|
||||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
|
@ -346,6 +351,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
}
|
||||
}
|
||||
}
|
||||
await _repositoryNoti.PushNotificationAsync(
|
||||
Guid.Parse("00000000-0000-0000-0000-000000000000"),
|
||||
$"{profile.Prefix?.Name}{profile.FirstName} {profile.LastName} ได้ทำการยื่นคำลาออก",
|
||||
$"{profile.Prefix?.Name}{profile.FirstName} {profile.LastName} ได้ทำการยื่นคำลาออก"
|
||||
);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success(retirementResign);
|
||||
|
|
@ -431,6 +441,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> AdminConfirm([FromBody] RetirementReasonRequest req, Guid id)
|
||||
{
|
||||
var updated = await _context.RetirementResigns
|
||||
.Include(x => x.Profile)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (updated == null)
|
||||
return Error(GlobalMessages.RetirementResignNotFound, 404);
|
||||
|
|
@ -458,6 +469,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> AdminReject([FromBody] RetirementReasonRequest req, Guid id)
|
||||
{
|
||||
var updated = await _context.RetirementResigns
|
||||
.Include(x => x.Profile)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (updated == null)
|
||||
return Error(GlobalMessages.RetirementResignNotFound, 404);
|
||||
|
|
@ -542,6 +554,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> OligarchConfirm([FromBody] RetirementReasonRequest req, Guid id)
|
||||
{
|
||||
var updated = await _context.RetirementResigns
|
||||
.Include(x => x.Profile)
|
||||
.ThenInclude(x => x.Prefix)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (updated == null)
|
||||
return Error(GlobalMessages.RetirementResignNotFound, 404);
|
||||
|
|
@ -552,6 +566,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
updated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
updated.LastUpdateUserId = UserId ?? "";
|
||||
updated.LastUpdatedAt = DateTime.Now;
|
||||
await _repositoryNoti.PushNotificationAsync(
|
||||
Guid.Parse("00000000-0000-0000-0000-000000000000"),
|
||||
$"คำขอลาออกขอ {updated.Profile.Prefix?.Name}{updated.Profile.FirstName} {updated.Profile.LastName} ได้รับการอนุมัติ",
|
||||
$"คำขอลาออกขอ {updated.Profile.Prefix?.Name}{updated.Profile.FirstName} {updated.Profile.LastName} ได้รับการอนุมัติ"
|
||||
);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
|
|
@ -871,6 +890,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> UpdateAppointQuestion([FromBody] RetirementQuestionAppointRequest req, Guid id)
|
||||
{
|
||||
var uppdated = await _context.RetirementQuestions.AsQueryable()
|
||||
.Include(x => x.RetirementResign)
|
||||
.ThenInclude(x => x.Profile)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (uppdated == null)
|
||||
return Error(GlobalMessages.RetirementQuestionNotFound);
|
||||
|
|
@ -879,6 +900,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
uppdated.LastUpdateUserId = UserId ?? "";
|
||||
uppdated.LastUpdatedAt = DateTime.Now;
|
||||
await _repositoryNoti.PushNotificationAsync(
|
||||
uppdated.RetirementResign.Profile.Id,
|
||||
$"การนัดสัมภาษณ์เหตุผลการลาออก {req.AppointDate.ToThaiFullDate()}",
|
||||
$"การนัดสัมภาษณ์เหตุผลการลาออก {req.AppointDate.ToThaiFullDate()}"
|
||||
);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue