diff --git a/CompanyManagment.Application/RollCallApplication.cs b/CompanyManagment.Application/RollCallApplication.cs index e73e4c3e..e618c3b0 100644 --- a/CompanyManagment.Application/RollCallApplication.cs +++ b/CompanyManagment.Application/RollCallApplication.cs @@ -447,8 +447,7 @@ public class RollCallApplication : IRollCallApplication return operation.Failed("کارمند در بازه انتخاب شده مرخصی ساعتی دارد"); } - if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate.Value.Date >= y.StartDateGr.Date && x.EndDate.Value.Date <= y.EndDateGr.Date))) - return operation.Failed("کارمند در بازه وارد شده غیر فعال است"); + @@ -458,7 +457,10 @@ public class RollCallApplication : IRollCallApplication _rollCallDomainService.GetEmployeeShiftDateByRollCallStartDate(command.WorkshopId, command.EmployeeId, x.StartDate!.Value,x.EndDate.Value); }); - + if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.ShiftDate.Date >= y.StartDateGr.Date && x.ShiftDate.Date <= y.EndDateGr.Date))) + return operation.Failed("کارمند در بازه وارد شده غیر فعال است"); + + if (newRollCallDates.Any(x => x.ShiftDate.Date != date.Date)) { return operation.Failed("حضور غیاب در حال ویرایش را نمیتوانید از تاریخ شیفت عقب تر یا جلو تر ببرید"); @@ -487,8 +489,8 @@ public class RollCallApplication : IRollCallApplication - if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate.Value.Date >= y.StartDateGr.Date - && x.EndDate.Value.Date <= y.EndDateGr.Date))) + if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.ShiftDate.Date >= y.StartDateGr.Date + && x.ShiftDate.Date <= y.EndDateGr.Date))) return operation.Failed("کارمند در بازه وارد شده غیر فعال است"); @@ -632,9 +634,6 @@ public class RollCallApplication : IRollCallApplication return operation.Failed("کارمند در بازه انتخاب شده مرخصی ساعتی دارد"); } - if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate.Value.Date >= y.StartDateGr.Date && x.EndDate.Value.Date <= y.EndDateGr.Date))) - return operation.Failed("کارمند در بازه وارد شده غیر فعال است"); - newRollCallDates.ForEach(x => { @@ -642,6 +641,11 @@ public class RollCallApplication : IRollCallApplication _rollCallDomainService.GetEmployeeShiftDateByRollCallStartDate(command.WorkshopId, command.EmployeeId, x.StartDate!.Value,x.EndDate.Value); }); + + if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.ShiftDate.Date >= y.StartDateGr.Date && x.ShiftDate.Date <= y.EndDateGr.Date))) + return operation.Failed("کارمند در بازه وارد شده غیر فعال است"); + + if (newRollCallDates.Any(x => x.ShiftDate.Date != date.Date)) { return operation.Failed("حضور غیاب در حال ویرایش را نمیتوانید از تاریخ شیفت عقب تر یا جلو تر ببرید"); @@ -664,7 +668,7 @@ public class RollCallApplication : IRollCallApplication && (y.StartDate.Value.Date <= x.ContractEndGr.Date)))) return operation.Failed("برای بازه های وارد شده فیش حقوقی ثبت شده است"); - if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.StartDate.Value.Date >= y.StartDateGr.Date && x.EndDate.Value.Date <= y.EndDateGr.Date))) + if (newRollCallDates == null || !newRollCallDates.All(x => employeeStatuses.Any(y => x.ShiftDate.Date >= y.StartDateGr.Date && x.ShiftDate.Date <= y.EndDateGr.Date))) return operation.Failed("کارمند در بازه وارد شده غیر فعال است"); var currentDayRollCall = employeeRollCalls.FirstOrDefault(x => x.EndDate == null);