From be18edf0a64a331c4fd19262bf25d3060a1878bb Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 25 Nov 2024 16:52:12 +0700 Subject: [PATCH] fix snap condition --- .../Repositories/Reports/InsigniaReportRepository.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs index 0d3f4dad..1aa1e44e 100644 --- a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs @@ -1099,11 +1099,15 @@ namespace BMA.EHR.Application.Repositories.Reports public async Task CalInsignaiRequestBkk() { var insigniaPeriods = await _dbContext.Set() + .Include(x => x.InsigniaRequests) .AsQueryable() .ToListAsync(); + insigniaPeriods = insigniaPeriods + .Where(x => x.StartDate < DateTime.Now.Date || x.InsigniaRequests.Count == 0).ToList(); + foreach (var insigniaPeriod in insigniaPeriods) { - if (insigniaPeriod.StartDate >= DateTime.Now.Date) + if (insigniaPeriod.StartDate >= DateTime.Now.Date || insigniaPeriod.InsigniaRequests.Count > 0) continue; //var organizationType = await _dbContext.Set().Where(x => x.Name == "หน่วยงาน").FirstOrDefaultAsync(); //if (organizationType == null)