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

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="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response> /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("detail/{id:length(36)}")] [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() var retirementDeceased = await _context.RetirementDeceaseds.AsQueryable()
.Include(x => x.RetirementDeceasedNotis) .Include(x => x.RetirementDeceasedNotis)
@ -448,12 +448,14 @@ namespace BMA.EHR.Retirement.Service.Controllers
if (retirementDeceased == null) if (retirementDeceased == null)
return Error(GlobalMessages.RetirementDeceasedNotFound, 404); return Error(GlobalMessages.RetirementDeceasedNotFound, 404);
foreach (var item in req.Persons)
{
var profile = await _context.Profiles.AsQueryable() var profile = await _context.Profiles.AsQueryable()
.Include(x => x.Prefix) .Include(x => x.Prefix)
.Include(x => x.Position) .Include(x => x.Position)
.FirstOrDefaultAsync(x => x.Id == req.ProfileId); .FirstOrDefaultAsync(x => x.Id == item.ProfileId);
if (profile == null) if (profile == null)
return Error(GlobalMessages.DataNotFound, 404); continue;
retirementDeceased.RetirementDeceasedNotis.Add(new RetirementDeceasedNoti retirementDeceased.RetirementDeceasedNotis.Add(new RetirementDeceasedNoti
{ {
@ -461,9 +463,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
Prefix = profile.Prefix == null ? "" : profile.Prefix.Name, Prefix = profile.Prefix == null ? "" : profile.Prefix.Name,
FirstName = profile.FirstName == null ? "" : profile.FirstName, FirstName = profile.FirstName == null ? "" : profile.FirstName,
LastName = profile.LastName == null ? "" : profile.LastName, LastName = profile.LastName == null ? "" : profile.LastName,
// IsSendMail = req.IsSendMail, IsSendMail = item.IsSendMail,
// IsSendInbox = req.IsSendInbox, IsSendInbox = item.IsSendInbox,
// IsSendNotification = req.IsSendNotification, IsSendNotification = item.IsSendNotification,
OrganizationName = profile.OrganizationOrganization == null ? "" : profile.OrganizationOrganization, OrganizationName = profile.OrganizationOrganization == null ? "" : profile.OrganizationOrganization,
PositionName = profile.Position == null ? null : profile.Position.Name, PositionName = profile.Position == null ? null : profile.Position.Name,
ReceiveUser = profile, ReceiveUser = profile,
@ -475,6 +477,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
LastUpdatedAt = DateTime.Now, LastUpdatedAt = DateTime.Now,
}); });
await _context.SaveChangesAsync(); await _context.SaveChangesAsync();
}
return Success(); return Success();
} }
@ -510,7 +513,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response> /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response> /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("noti/{id:length(36)}")] [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() var items = await _context.RetirementDeceasedNotis.AsQueryable()
.Include(x => x.ReceiveUser) .Include(x => x.ReceiveUser)
@ -522,7 +525,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
foreach (var item in items) foreach (var item in items)
{ {
var prefix = item.RetirementDeceased.Profile.Prefix == null ? "" : item.RetirementDeceased.Profile.Prefix.Name; 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 != null)
{ {
if (profile.IsSendInbox == true) if (profile.IsSendInbox == true)
@ -547,6 +550,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
}; };
_context.Notifications.Add(noti); _context.Notifications.Add(noti);
} }
item.IsSendMail = profile.IsSendMail;
item.IsSendInbox = profile.IsSendInbox; item.IsSendInbox = profile.IsSendInbox;
item.IsSendNotification = profile.IsSendNotification; item.IsSendNotification = profile.IsSendNotification;
} }

View file

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

View file

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