diff --git a/CompanyManagment.App.Contracts/Leave/LeavErrorViewModel.cs b/CompanyManagment.App.Contracts/Leave/LeavErrorViewModel.cs index 24953c80..d4fcfe49 100644 --- a/CompanyManagment.App.Contracts/Leave/LeavErrorViewModel.cs +++ b/CompanyManagment.App.Contracts/Leave/LeavErrorViewModel.cs @@ -14,5 +14,8 @@ namespace CompanyManagment.App.Contracts.Leave public string LeftWorlErrMessage { get; set; } public bool HasNotContract { get; set; } public string ContractErrMessage { get; set; } + + public bool HasHolidayError { get; set; } + public string HolidayErrorMessage { get; set; } } } diff --git a/CompanyManagment.Application/LeaveApplication.cs b/CompanyManagment.Application/LeaveApplication.cs index b504cab5..a532608e 100644 --- a/CompanyManagment.Application/LeaveApplication.cs +++ b/CompanyManagment.Application/LeaveApplication.cs @@ -96,6 +96,8 @@ public class LeaveApplication : ILeaveApplication return op.Failed(checkErr.ContractErrMessage); if (checkErr.HasLeftWork) return op.Failed(checkErr.LeftWorlErrMessage); + if (checkErr.HasHolidayError) + return op.Failed(checkErr.HolidayErrorMessage); if (start > end) return op.Failed("تارخ شروع از پایان بزرگتر است"); @@ -304,6 +306,8 @@ public class LeaveApplication : ILeaveApplication return op.Failed(checkErr.CheckoutErrMessage); if (checkErr.HasLeftWork) return op.Failed(checkErr.LeftWorlErrMessage); + if (checkErr.HasHolidayError) + return op.Failed(checkErr.HolidayErrorMessage); if (start > end) return op.Failed("تارخ شروع از پایان بزرگتر است"); diff --git a/CompanyManagment.EFCore/Repository/LeaveRepository.cs b/CompanyManagment.EFCore/Repository/LeaveRepository.cs index d2fe7013..ef53d722 100644 --- a/CompanyManagment.EFCore/Repository/LeaveRepository.cs +++ b/CompanyManagment.EFCore/Repository/LeaveRepository.cs @@ -454,6 +454,17 @@ public class LeaveRepository : RepositoryBase, ILeaveRepository #endregion + #region HolidayError + + if (_context.HolidayItems.Any(x => startLeav.Date == x.Holidaydate.Date) || + startLeav.DayOfWeek == DayOfWeek.Friday) + { + res.HasHolidayError = true; + res.HolidayErrorMessage = "شما نمیتوانید در روز های تعطیل مرخصی ثبت کنید"; + } + + #endregion + return res; }