From 390eb7296ba1ae90ad3c2c0403398c3b644c6477 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 13 Sep 2023 16:54:19 +0700 Subject: [PATCH] =?UTF-8?q?gen=20=E0=B8=AB=E0=B8=B1=E0=B8=A7=E0=B8=81?= =?UTF-8?q?=E0=B8=A3=E0=B8=B0=E0=B8=94=E0=B8=B2=E0=B8=A9=E0=B8=AB=E0=B8=99?= =?UTF-8?q?=E0=B8=B1=E0=B8=87=E0=B8=AA=E0=B8=B7=E0=B8=AD=E0=B9=80=E0=B8=A7?= =?UTF-8?q?=E0=B8=B5=E0=B8=A2=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reports/RetireReportRepository.cs | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs index 561ddd3e..a9bcebc4 100644 --- a/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs @@ -1,5 +1,6 @@ using BMA.EHR.Application.Common.Interfaces; using BMA.EHR.Domain.Extensions; +using BMA.EHR.Domain.Models.Organizations; using BMA.EHR.Domain.Models.Retirement; using Microsoft.AspNetCore.Hosting; using Microsoft.EntityFrameworkCore; @@ -186,6 +187,58 @@ namespace BMA.EHR.Application.Repositories.Reports } #endregion + #region หัวกระดาษหนังสือเวียน + public async Task GetHeadRetirementDeceasedAsync(Guid id) + { + var data = await _dbContext.Set().AsQueryable() + .Include(x => x.Profile) + .Where(x => x.Id == id) + .FirstOrDefaultAsync(); + var oc = ""; + if (data == null) + return new + { + Oc = oc, + Number = $"กท /", + Date = "", + Subject = "ข้าราชการถึงแก่กรรม", + Send = "หัวหน้าสำนักงาน ก.ก.", + }; + + if (data.Profile.OcId != null) + { + var organization = await _dbContext.Set().AsQueryable() + .Where(x => x.Id == data.Profile.OcId) + .FirstOrDefaultAsync(); + if (organization != null) + { + var organizationAgency = await _dbContext.Set().AsQueryable() + .Where(x => x.Id == organization.OrganizationAgencyId) + .FirstOrDefaultAsync(); + if (organizationAgency != null) + { + var agency = await _dbContext.Set().AsQueryable() + .Where(x => x.Id == organizationAgency.Id) + .FirstOrDefaultAsync(); + if (agency != null) + { + oc = agency.OrganizationOrganization?.Name; + } + } + } + } + + return new + { + Oc = oc, + Number = $"กท /{data.CreatedAt.Year.ToThaiYear()}", + Date = data.CreatedAt.ToThaiFullDate().ToString().ToThaiNumber(), + Subject = "ข้าราชการถึงแก่กรรม", + Send = "หัวหน้าสำนักงาน ก.ก.", + }; + } + #endregion + #endregion } }