add validation for leave

This commit is contained in:
2025-10-01 16:32:58 +03:30
parent d0928804ee
commit 8fb10ba5b0
3 changed files with 18 additions and 0 deletions

View File

@@ -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; }
}
}

View File

@@ -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("تارخ شروع از پایان بزرگتر است");

View File

@@ -454,6 +454,17 @@ public class LeaveRepository : RepositoryBase<long, Leave>, 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;
}