From 0ddcb3653ac210918b08dfaba8375ff84d275ac1 Mon Sep 17 00:00:00 2001 From: SamSys Date: Sat, 24 May 2025 17:16:02 +0330 Subject: [PATCH] FirstDayOfMonth --- CompanyManagment.EFCore/Repository/RollCallRepository.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CompanyManagment.EFCore/Repository/RollCallRepository.cs b/CompanyManagment.EFCore/Repository/RollCallRepository.cs index 2f384a23..a54f063c 100644 --- a/CompanyManagment.EFCore/Repository/RollCallRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallRepository.cs @@ -151,6 +151,7 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos //حضور غیاب در پرینت فیش حقوقی رسمی public List GetEmployeeRollCallsForMonth(long employeeId, long workshopId, DateTime startMonthDay, DateTime endMonthDay) { + var firstDayOfMonth = $"{startMonthDay.ToFarsi().Substring(0,8)}01".ToGeorgianDateTime(); //گرفتن ساعت استراحت پرسنل از تنظیمات #region breakTime @@ -169,8 +170,8 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos x.WorkshopId == workshopId && x.EmployeeId == employeeId && x.EndLeave.Date >= startMonthDay.Date && x.StartLeave.Date <= endMonthDay.Date).ToList(); - var year = Convert.ToInt32(startMonthDay.ToFarsi().Substring(0, 4)); - var month = Convert.ToInt32(startMonthDay.ToFarsi().Substring(5, 2)); + var year = Convert.ToInt32(firstDayOfMonth.ToFarsi().Substring(0, 4)); + var month = Convert.ToInt32(firstDayOfMonth.ToFarsi().Substring(5, 2)); var firstDayOfCurrentMonth = new DateTime(year, month, 1, new PersianCalendar()); @@ -193,7 +194,7 @@ public class RollCallRepository : RepositoryBase, IRollCallRepos HolidayYear = startMonthDay.ToFarsiYear() }); //all the dates from start to end, to be compared with present days to get absent dates - var completeDaysList = Enumerable.Range(0, dateRange).Select(offset => startMonthDay.AddDays(offset).Date).ToList(); + var completeDaysList = Enumerable.Range(0, dateRange).Select(offset => firstDayOfCurrentMonth.AddDays(offset).Date).ToList(); var absentRecords = completeDaysList .ExceptBy(rollCalls.Select(x => x.ShiftDate.Date), y => y.Date)