From 5280b712915559abb954f391431bd66965667d84 Mon Sep 17 00:00:00 2001 From: "DESKTOP-2S5P7D1\\Windows 10" Date: Fri, 1 Sep 2023 15:48:51 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=88=E0=B9=89=E0=B8=87=E0=B8=AB?= =?UTF-8?q?=E0=B8=99=E0=B8=B1=E0=B8=87=E0=B8=AA=E0=B8=B7=E0=B8=AD=E0=B9=80?= =?UTF-8?q?=E0=B8=A7=E0=B8=B5=E0=B8=A2=E0=B8=99=E0=B9=83=E0=B8=AB=E0=B9=89?= =?UTF-8?q?=E0=B8=AB=E0=B8=B1=E0=B8=A7=E0=B8=AB=E0=B8=99=E0=B9=89=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RetirementDeceasedController.cs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs index 883ac188..8a8d77d1 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs @@ -215,6 +215,7 @@ namespace BMA.EHR.Retirement.Service.Controllers public async Task> Post([FromForm] RetirementDeceasedRequest req) { var profile = await _context.Profiles + .Include(x => x.Prefix) .FirstOrDefaultAsync(x => x.Id == req.ProfileId); if (profile == null) return Error(GlobalMessages.DataNotFound, 404); @@ -284,6 +285,45 @@ namespace BMA.EHR.Retirement.Service.Controllers LastUpdatedAt = DateTime.Now, }); } + var orgPos = await _context.ProfilePositions + .Include(x => x.Profile) + .ThenInclude(x => x!.Prefix) + .Include(x => x.OrganizationPosition) + .ThenInclude(x => x!.Organization) + .ThenInclude(x => x!.OrganizationOrganization) + .Include(x => x.OrganizationPosition) + .ThenInclude(x => x!.PositionMaster) + .ThenInclude(x => x!.PositionPath) + .Where(x => x.OrganizationPosition!.IsDirector! == true) + .Where(x => x.OrganizationPosition!.Organization!.Id == profile.OcId) + .FirstOrDefaultAsync(); + + if (orgPos != null) + { + if (orgPos.Profile != null) + { + retirementDeceased.RetirementDeceasedNotis.Add(new RetirementDeceasedNoti + { + CitizenId = orgPos!.Profile!.CitizenId!, + Prefix = orgPos!.Profile!.Prefix!.Name, + FirstName = orgPos!.Profile!.FirstName!, + LastName = orgPos!.Profile!.LastName!, + // IsSendMail = req.IsSendMail, + // IsSendInbox = req.IsSendInbox, + // IsSendNotification = req.IsSendNotification, + OrganizationName = orgPos!.OrganizationPosition!.Organization!.OrganizationOrganization!.Name, + PositionName = orgPos!.OrganizationPosition!.PositionMaster!.PositionPath!.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();