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();