แก้บัค หนังสือเวียน

This commit is contained in:
DESKTOP-2S5P7D1\Windows 10 2023-09-01 18:07:28 +07:00
parent 5280b71291
commit 1147011980
3 changed files with 36 additions and 32 deletions

View file

@ -440,7 +440,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("detail/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateDetail([FromForm] RetirementDeceasedAddNotiRequest req, Guid id)
public async Task<ActionResult<ResponseObject>> UpdateDetail([FromBody] RetirementDeceasedAddNotiPersonRequest req, Guid id)
{
var retirementDeceased = await _context.RetirementDeceaseds.AsQueryable()
.Include(x => x.RetirementDeceasedNotis)
@ -448,33 +448,36 @@ namespace BMA.EHR.Retirement.Service.Controllers
if (retirementDeceased == null)
return Error(GlobalMessages.RetirementDeceasedNotFound, 404);
var profile = await _context.Profiles.AsQueryable()
.Include(x => x.Prefix)
.Include(x => x.Position)
.FirstOrDefaultAsync(x => x.Id == req.ProfileId);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
retirementDeceased.RetirementDeceasedNotis.Add(new RetirementDeceasedNoti
foreach (var item in req.Persons)
{
CitizenId = profile.CitizenId == null ? "" : profile.CitizenId,
Prefix = profile.Prefix == null ? "" : profile.Prefix.Name,
FirstName = profile.FirstName == null ? "" : profile.FirstName,
LastName = profile.LastName == null ? "" : profile.LastName,
// IsSendMail = req.IsSendMail,
// IsSendInbox = req.IsSendInbox,
// IsSendNotification = req.IsSendNotification,
OrganizationName = profile.OrganizationOrganization == null ? "" : profile.OrganizationOrganization,
PositionName = profile.Position == null ? null : profile.Position.Name,
ReceiveUser = profile,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
await _context.SaveChangesAsync();
var profile = await _context.Profiles.AsQueryable()
.Include(x => x.Prefix)
.Include(x => x.Position)
.FirstOrDefaultAsync(x => x.Id == item.ProfileId);
if (profile == null)
continue;
retirementDeceased.RetirementDeceasedNotis.Add(new RetirementDeceasedNoti
{
CitizenId = profile.CitizenId == null ? "" : profile.CitizenId,
Prefix = profile.Prefix == null ? "" : profile.Prefix.Name,
FirstName = profile.FirstName == null ? "" : profile.FirstName,
LastName = profile.LastName == null ? "" : profile.LastName,
IsSendMail = item.IsSendMail,
IsSendInbox = item.IsSendInbox,
IsSendNotification = item.IsSendNotification,
OrganizationName = profile.OrganizationOrganization == null ? "" : profile.OrganizationOrganization,
PositionName = profile.Position == null ? null : profile.Position.Name,
ReceiveUser = profile,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
await _context.SaveChangesAsync();
}
return Success();
}
@ -510,7 +513,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("noti/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> NotiDeceased([FromForm] RetirementDeceasedAddNotiPersonRequest req, Guid id)
public async Task<ActionResult<ResponseObject>> NotiDeceased([FromBody] RetirementDeceasedAddNotiPersonRequest req, Guid id)
{
var items = await _context.RetirementDeceasedNotis.AsQueryable()
.Include(x => x.ReceiveUser)
@ -522,7 +525,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
foreach (var item in items)
{
var prefix = item.RetirementDeceased.Profile.Prefix == null ? "" : item.RetirementDeceased.Profile.Prefix.Name;
var profile = req.Person.FirstOrDefault(x => x.ProfileId == item.ReceiveUser.Id);
var profile = req.Persons.FirstOrDefault(x => x.ProfileId == item.ReceiveUser.Id);
if (profile != null)
{
if (profile.IsSendInbox == true)
@ -547,6 +550,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
};
_context.Notifications.Add(noti);
}
item.IsSendMail = profile.IsSendMail;
item.IsSendInbox = profile.IsSendInbox;
item.IsSendNotification = profile.IsSendNotification;
}

View file

@ -514,7 +514,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
.FirstOrDefaultAsync(x => x.Id == id);
if (updated == null)
return Error(GlobalMessages.RetirementResignNotFound, 404);
if ((DateTime.Now - updated.CreatedAt).TotalDays > 90)
if ((DateTime.Now - updated.CreatedAt).TotalDays >= 90)
return Error("สามารถยับยั้งได้ไม่เกิน 90 วัน");
// updated.Status = "REJECT";
updated.CommanderReject = true;
@ -571,7 +571,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
.FirstOrDefaultAsync(x => x.Id == id);
if (updated == null)
return Error(GlobalMessages.RetirementResignNotFound, 404);
if ((DateTime.Now - updated.CreatedAt).TotalDays > 90)
if ((DateTime.Now - updated.CreatedAt).TotalDays >= 90)
return Error("สามารถยับยั้งได้ไม่เกิน 90 วัน");
updated.Status = "REJECT";
updated.OligarchReject = true;

View file

@ -5,7 +5,7 @@ namespace BMA.EHR.Retirement.Service.Requests
{
public class RetirementDeceasedAddNotiPersonRequest
{
public List<RetirementDeceasedAddNotiPerson> Person { get; set; }
public List<RetirementDeceasedAddNotiPerson> Persons { get; set; }
}
public class RetirementDeceasedAddNotiPerson
{