แก้ api พ้นราชการ

This commit is contained in:
Kittapath 2024-05-21 19:41:55 +07:00
parent 2a3a151f34
commit 63b02dcc4c
19 changed files with 54771 additions and 431 deletions

View file

@ -1249,13 +1249,13 @@ namespace BMA.EHR.Application.Repositories.Commands
// 2. Query
var appointPeople = await _dbContext.Set<RetirementResign>()
.Include(x => x.Profile)
.ThenInclude(x => x.Prefix)
//.Include(x => x.Profile)
//.ThenInclude(x => x.Prefix)
//.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId)
.Where(x => !otherCommandReceivers.Contains(x.Profile!.CitizenId!))
.Where(x => x.Profile.ProfileType == "officer")
.Where(x => !otherCommandReceivers.Contains(x.citizenId))
// .Where(x => x.Profile.ProfileType == "officer")
.Where(x => x.Status.Trim().ToUpper() == "REPORT")
.OrderBy(x => x.Profile!.CitizenId)
.OrderBy(x => x.citizenId)
.ToListAsync();
// 3. Create new Record
@ -1265,10 +1265,10 @@ namespace BMA.EHR.Application.Repositories.Commands
var receiver = new CommandReceiver
{
Sequence = seq,
CitizenId = item.Profile!.CitizenId!,
Prefix = item.Profile!.Prefix!.Name,
FirstName = item.Profile!.FirstName!,
LastName = item.Profile!.LastName!,
CitizenId = item.citizenId,
Prefix = item.prefix,
FirstName = item.firstName,
LastName = item.lastName,
RefPlacementProfileId = item.Id,
Amount = item.AmountOld,
};
@ -1691,13 +1691,13 @@ namespace BMA.EHR.Application.Repositories.Commands
// 2. Query
var appointPeople = await _dbContext.Set<RetirementResign>()
.Include(x => x.Profile)
.ThenInclude(x => x.Prefix)
//.Include(x => x.Profile)
//.ThenInclude(x => x.Prefix)
//.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId)
.Where(x => !otherCommandReceivers.Contains(x.Profile!.CitizenId!))
.Where(x => x.Profile.ProfileType == "employee")
.Where(x => !otherCommandReceivers.Contains(x.citizenId))
// .Where(x => x.Profile.ProfileType == "employee")
.Where(x => x.Status.Trim().ToUpper() == "REPORT")
.OrderBy(x => x.Profile!.CitizenId)
.OrderBy(x => x.citizenId)
.ToListAsync();
// 3. Create new Record
@ -1707,10 +1707,10 @@ namespace BMA.EHR.Application.Repositories.Commands
var receiver = new CommandReceiver
{
Sequence = seq,
CitizenId = item.Profile!.CitizenId!,
Prefix = item.Profile!.Prefix!.Name,
FirstName = item.Profile!.FirstName!,
LastName = item.Profile!.LastName!,
CitizenId = item.citizenId,
Prefix = item.prefix,
FirstName = item.firstName,
LastName = item.lastName,
RefPlacementProfileId = item.Id,
Amount = item.AmountOld,
};
@ -5644,7 +5644,7 @@ namespace BMA.EHR.Application.Repositories.Commands
//var lastSarary = data.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault();
//var order = 1;
//if (lastSarary != null && lastSarary.Order != null)
//order = lastSarary.Order.Value + 1;
//order = lastSarary.Order.Value + 1;
// var salary = new ProfileSalary
// {
@ -6526,85 +6526,85 @@ namespace BMA.EHR.Application.Repositories.Commands
foreach (var recv in command.Receivers)
{
var data = await _dbContext.Set<RetirementResign>()
.Include(x => x.Profile)
.ThenInclude(x => x.Salaries)
.ThenInclude(x => x.PositionLevel)
//.Include(x => x.Profile)
//.ThenInclude(x => x.Salaries)
//.ThenInclude(x => x.PositionLevel)
.FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId);
if (data == null)
throw new Exception(GlobalMessages.DataNotFound);
data.Profile.IsActive = false;
data.Profile.IsLeave = true;
data.Profile.LeaveReason = "ลาออกจากราชการ";
data.Profile.LeaveDate = command.CommandAffectDate;
// data.Profile.IsActive = false;
// data.Profile.IsLeave = true;
// data.Profile.LeaveReason = "ลาออกจากราชการ";
// data.Profile.LeaveDate = command.CommandAffectDate;
var lastSarary = data.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault();
var order = 1;
if (lastSarary != null && lastSarary.Order != null)
order = lastSarary.Order.Value + 1;
// var lastSarary = data.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault();
// var order = 1;
// if (lastSarary != null && lastSarary.Order != null)
// order = lastSarary.Order.Value + 1;
var salary = new ProfileSalary
{
Order = order,
Date = command.CommandAffectDate,
Amount = lastSarary == null ? null : lastSarary.Amount,
PositionSalaryAmount = lastSarary == null ? null : lastSarary.PositionSalaryAmount,
MouthSalaryAmount = lastSarary == null ? null : lastSarary.MouthSalaryAmount,
SalaryClass = "",
SalaryRef = "คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
// var salary = new ProfileSalary
// {
// Order = order,
// Date = command.CommandAffectDate,
// Amount = lastSarary == null ? null : lastSarary.Amount,
// PositionSalaryAmount = lastSarary == null ? null : lastSarary.PositionSalaryAmount,
// MouthSalaryAmount = lastSarary == null ? null : lastSarary.MouthSalaryAmount,
// SalaryClass = "",
// SalaryRef = "คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
OcId = lastSarary == null ? null : lastSarary.OcId,
// OcId = lastSarary == null ? null : lastSarary.OcId,
PositionId = lastSarary == null ? null : lastSarary.PositionId,
// PositionId = lastSarary == null ? null : lastSarary.PositionId,
PositionLevel = lastSarary == null ? null : lastSarary.PositionLevel,
PositionLineId = lastSarary == null ? null : lastSarary.PositionLineId,
PositionTypeId = lastSarary == null ? null : lastSarary.PositionTypeId,
OrganizationShortNameId = lastSarary == null ? null : lastSarary.OrganizationShortNameId,
PosNoId = lastSarary == null ? null : lastSarary.PosNoId,
// PositionLevel = lastSarary == null ? null : lastSarary.PositionLevel,
// PositionLineId = lastSarary == null ? null : lastSarary.PositionLineId,
// PositionTypeId = lastSarary == null ? null : lastSarary.PositionTypeId,
// OrganizationShortNameId = lastSarary == null ? null : lastSarary.OrganizationShortNameId,
// PosNoId = lastSarary == null ? null : lastSarary.PosNoId,
CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
RefCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
CommandTypeName = command.CommandType.Name,
// CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
// RefCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
// CommandTypeName = command.CommandType.Name,
PositionEmployeeGroupId = null,
PositionEmployeeLevelId = null,
PositionEmployeePositionId = null,
PositionEmployeePositionSideId = null,
PosNoEmployee = "",
// PositionEmployeeGroupId = null,
// PositionEmployeeLevelId = null,
// PositionEmployeePositionId = null,
// PositionEmployeePositionSideId = null,
// PosNoEmployee = "",
//PositionPathSideId = lastSarary == null ? null : lastSarary.PositionPathSideId == null,
PositionExecutiveId = lastSarary == null ? null : lastSarary.PositionExecutiveId,
//PositionExecutiveSideId = lastSarary == null ? null : lastSarary.PositionExecutiveSideId,
// //PositionPathSideId = lastSarary == null ? null : lastSarary.PositionPathSideId == null,
// PositionExecutiveId = lastSarary == null ? null : lastSarary.PositionExecutiveId,
// //PositionExecutiveSideId = lastSarary == null ? null : lastSarary.PositionExecutiveSideId,
IsActive = true,
CreatedAt = DateTime.Now,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
// IsActive = true,
// CreatedAt = DateTime.Now,
// CreatedFullName = FullName ?? "System Administrator",
// CreatedUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "",
};
// };
if (lastSarary != null && lastSarary.PositionPathSideId != null) salary.PositionPathSideId = lastSarary.PositionPathSideId;
if (lastSarary != null && lastSarary.PositionExecutiveSideId != null) salary.PositionExecutiveSideId = lastSarary.PositionExecutiveSideId;
// if (lastSarary != null && lastSarary.PositionPathSideId != null) salary.PositionPathSideId = lastSarary.PositionPathSideId;
// if (lastSarary != null && lastSarary.PositionExecutiveSideId != null) salary.PositionExecutiveSideId = lastSarary.PositionExecutiveSideId;
data.Profile.Salaries.Add(salary);
// data.Profile.Salaries.Add(salary);
// remove profile position
var profilePosition = await _dbContext.Set<ProfilePosition>()
.Include(x => x.Profile)
.Include(x => x.OrganizationPosition)
.FirstOrDefaultAsync(x => x.Profile!.Id == data.Profile.Id);
if (profilePosition != null)
_dbContext.Set<ProfilePosition>().Remove(profilePosition);
// // remove profile position
// var profilePosition = await _dbContext.Set<ProfilePosition>()
// .Include(x => x.Profile)
// .Include(x => x.OrganizationPosition)
// .FirstOrDefaultAsync(x => x.Profile!.Id == data.Profile.Id);
// if (profilePosition != null)
// _dbContext.Set<ProfilePosition>().Remove(profilePosition);
// update placementstatus
// // update placementstatus
data.Status = "DONE";
await _dbContext.SaveChangesAsync();
@ -6620,7 +6620,7 @@ namespace BMA.EHR.Application.Repositories.Commands
{
Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คุณได้รับคำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Profile.Id,
KeycloakUserId = data.CreatedUserId,
Payload = payload_str,
};
_dbContext.Set<Inbox>().Add(inbox);
@ -6628,7 +6628,7 @@ namespace BMA.EHR.Application.Repositories.Commands
var noti = new Notification
{
Body = $"คุณได้รับคำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Profile.Id,
KeycloakUserId = data.CreatedUserId,
Type = "LINK",
Payload = payload_str,
};
@ -6636,44 +6636,44 @@ namespace BMA.EHR.Application.Repositories.Commands
await _dbContext.SaveChangesAsync();
}
// send cc noti inbox
foreach (var cc in command.Deployments)
{
var pf = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.CitizenId == cc.CitizenId);
if (pf != null)
{
if (cc.IsSendInbox)
{
var inbox = new Inbox
{
Subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = pf.Id,
Payload = payload_str,
};
_dbContext.Set<Inbox>().Add(inbox);
}
// // send cc noti inbox
// foreach (var cc in command.Deployments)
// {
// var pf = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.CitizenId == cc.CitizenId);
// if (pf != null)
// {
// if (cc.IsSendInbox)
// {
// var inbox = new Inbox
// {
// Subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// Body = $"คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// ReceiverUserId = pf.Id,
// Payload = payload_str,
// };
// _dbContext.Set<Inbox>().Add(inbox);
// }
if (cc.IsSendMail)
{
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
var subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
var body = $"คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
_emailSenderService.SendMail(subject, body, "dev@frappet.com");
}
// if (cc.IsSendMail)
// {
// // TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// // Send noti inbox and email
// var subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
// var body = $"คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
// _emailSenderService.SendMail(subject, body, "dev@frappet.com");
// }
var noti = new Notification
{
Body = $"คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = pf.Id,
Type = "LINK",
Payload = payload_str,
};
_dbContext.Set<Notification>().Add(noti);
}
}
// var noti = new Notification
// {
// Body = $"คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// ReceiverUserId = pf.Id,
// Type = "LINK",
// Payload = payload_str,
// };
// _dbContext.Set<Notification>().Add(noti);
// }
// }
// change command status
var cmdStatus = await _dbContext.Set<CommandStatus>().FirstOrDefaultAsync(x => x.Sequence == 5);
@ -7689,76 +7689,76 @@ namespace BMA.EHR.Application.Repositories.Commands
foreach (var recv in command.Receivers)
{
var data = await _dbContext.Set<RetirementResign>()
.Include(x => x.Profile)
.ThenInclude(x => x.Salaries)
.ThenInclude(x => x.PositionLevel)
//.Include(x => x.Profile)
//.ThenInclude(x => x.Salaries)
//.ThenInclude(x => x.PositionLevel)
.FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId);
if (data == null)
throw new Exception(GlobalMessages.DataNotFound);
data.Profile.IsActive = false;
data.Profile.IsLeave = true;
data.Profile.LeaveReason = "ลาออกจากราชการ";
data.Profile.LeaveDate = command.CommandAffectDate;
// data.Profile.IsActive = false;
// data.Profile.IsLeave = true;
// data.Profile.LeaveReason = "ลาออกจากราชการ";
// data.Profile.LeaveDate = command.CommandAffectDate;
var lastSarary = data.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault();
var order = 1;
if (lastSarary != null && lastSarary.Order != null)
order = lastSarary.Order.Value + 1;
// var lastSarary = data.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault();
// var order = 1;
// if (lastSarary != null && lastSarary.Order != null)
// order = lastSarary.Order.Value + 1;
var salary = new ProfileSalary
{
Order = order,
Date = command.CommandAffectDate,
Amount = lastSarary == null ? null : lastSarary.Amount,
PositionSalaryAmount = lastSarary == null ? null : lastSarary.PositionSalaryAmount,
MouthSalaryAmount = lastSarary == null ? null : lastSarary.MouthSalaryAmount,
SalaryClass = "",
SalaryRef = "คำสั่งให้ลูกจ้างออกจากราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
// var salary = new ProfileSalary
// {
// Order = order,
// Date = command.CommandAffectDate,
// Amount = lastSarary == null ? null : lastSarary.Amount,
// PositionSalaryAmount = lastSarary == null ? null : lastSarary.PositionSalaryAmount,
// MouthSalaryAmount = lastSarary == null ? null : lastSarary.MouthSalaryAmount,
// SalaryClass = "",
// SalaryRef = "คำสั่งให้ลูกจ้างออกจากราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
OcId = lastSarary == null ? null : lastSarary.OcId,
// OcId = lastSarary == null ? null : lastSarary.OcId,
PositionLevel = lastSarary == null ? null : lastSarary.PositionLevel,
PositionLineId = lastSarary == null ? null : lastSarary.PositionLineId,
PositionTypeId = lastSarary == null ? null : lastSarary.PositionTypeId,
OrganizationShortNameId = lastSarary == null ? null : lastSarary.OrganizationShortNameId,
PosNoId = lastSarary == null ? null : lastSarary.PosNoId,
// PositionLevel = lastSarary == null ? null : lastSarary.PositionLevel,
// PositionLineId = lastSarary == null ? null : lastSarary.PositionLineId,
// PositionTypeId = lastSarary == null ? null : lastSarary.PositionTypeId,
// OrganizationShortNameId = lastSarary == null ? null : lastSarary.OrganizationShortNameId,
// PosNoId = lastSarary == null ? null : lastSarary.PosNoId,
CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
RefCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
CommandTypeName = command.CommandType.Name,
// CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
// RefCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
// CommandTypeName = command.CommandType.Name,
PositionEmployeeGroupId = null,
PositionEmployeeLevelId = null,
PositionEmployeePositionId = null,
PositionEmployeePositionSideId = null,
PosNoEmployee = "",
// PositionEmployeeGroupId = null,
// PositionEmployeeLevelId = null,
// PositionEmployeePositionId = null,
// PositionEmployeePositionSideId = null,
// PosNoEmployee = "",
//PositionPathSideId = lastSarary == null ? null : lastSarary.PositionPathSideId == null,
PositionExecutiveId = lastSarary == null ? null : lastSarary.PositionExecutiveId,
//PositionExecutiveSideId = lastSarary == null ? null : lastSarary.PositionExecutiveSideId,
// //PositionPathSideId = lastSarary == null ? null : lastSarary.PositionPathSideId == null,
// PositionExecutiveId = lastSarary == null ? null : lastSarary.PositionExecutiveId,
// //PositionExecutiveSideId = lastSarary == null ? null : lastSarary.PositionExecutiveSideId,
IsActive = true,
CreatedAt = DateTime.Now,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
// IsActive = true,
// CreatedAt = DateTime.Now,
// CreatedFullName = FullName ?? "System Administrator",
// CreatedUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "",
};
// };
if (lastSarary != null && lastSarary.PositionPathSideId != null) salary.PositionPathSideId = lastSarary.PositionPathSideId;
if (lastSarary != null && lastSarary.PositionExecutiveSideId != null) salary.PositionExecutiveSideId = lastSarary.PositionExecutiveSideId;
// if (lastSarary != null && lastSarary.PositionPathSideId != null) salary.PositionPathSideId = lastSarary.PositionPathSideId;
// if (lastSarary != null && lastSarary.PositionExecutiveSideId != null) salary.PositionExecutiveSideId = lastSarary.PositionExecutiveSideId;
data.Profile.Salaries.Add(salary);
// data.Profile.Salaries.Add(salary);
// update placementstatus
// // update placementstatus
data.Status = "DONE";
await _dbContext.SaveChangesAsync();
@ -7774,7 +7774,7 @@ namespace BMA.EHR.Application.Repositories.Commands
{
Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คุณได้รับคำสั่งให้ลูกจ้างออกจากราชการ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Profile.Id,
KeycloakUserId = data.CreatedUserId,
Payload = payload_str,
};
_dbContext.Set<Inbox>().Add(inbox);
@ -7782,7 +7782,7 @@ namespace BMA.EHR.Application.Repositories.Commands
var noti = new Notification
{
Body = $"คุณได้รับคำสั่งให้ลูกจ้างออกจากราชการ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Profile.Id,
KeycloakUserId = data.CreatedUserId,
Type = "LINK",
Payload = payload_str,
};
@ -7790,44 +7790,44 @@ namespace BMA.EHR.Application.Repositories.Commands
await _dbContext.SaveChangesAsync();
}
// send cc noti inbox
foreach (var cc in command.Deployments)
{
var pf = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.CitizenId == cc.CitizenId);
if (pf != null)
{
if (cc.IsSendInbox)
{
var inbox = new Inbox
{
Subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คำสั่งให้ลูกจ้างออกจากราชการ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = pf.Id,
Payload = payload_str,
};
_dbContext.Set<Inbox>().Add(inbox);
}
// // send cc noti inbox
// foreach (var cc in command.Deployments)
// {
// var pf = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.CitizenId == cc.CitizenId);
// if (pf != null)
// {
// if (cc.IsSendInbox)
// {
// var inbox = new Inbox
// {
// Subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// Body = $"คำสั่งให้ลูกจ้างออกจากราชการ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// ReceiverUserId = pf.Id,
// Payload = payload_str,
// };
// _dbContext.Set<Inbox>().Add(inbox);
// }
if (cc.IsSendMail)
{
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
var subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
var body = $"คำสั่งให้ลูกจ้างออกจากราชการ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
_emailSenderService.SendMail(subject, body, "dev@frappet.com");
}
// if (cc.IsSendMail)
// {
// // TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// // Send noti inbox and email
// var subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
// var body = $"คำสั่งให้ลูกจ้างออกจากราชการ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
// _emailSenderService.SendMail(subject, body, "dev@frappet.com");
// }
var noti = new Notification
{
Body = $"คำสั่งให้ลูกจ้างออกจากราชการ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = pf.Id,
Type = "LINK",
Payload = payload_str,
};
_dbContext.Set<Notification>().Add(noti);
}
}
// var noti = new Notification
// {
// Body = $"คำสั่งให้ลูกจ้างออกจากราชการ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// ReceiverUserId = pf.Id,
// Type = "LINK",
// Payload = payload_str,
// };
// _dbContext.Set<Notification>().Add(noti);
// }
// }
// change command status
var cmdStatus = await _dbContext.Set<CommandStatus>().FirstOrDefaultAsync(x => x.Sequence == 5);