diff --git a/Company.Domain/LeaveAgg/ILeaveRepository.cs b/Company.Domain/LeaveAgg/ILeaveRepository.cs index 9cc200c5..403de39f 100644 --- a/Company.Domain/LeaveAgg/ILeaveRepository.cs +++ b/Company.Domain/LeaveAgg/ILeaveRepository.cs @@ -21,7 +21,7 @@ public interface ILeaveRepository : IRepository #region Vafa - List LastLeaveMain(long workshopId, int pageIndex); + List LastLeaveMain(LeaveSearchModel searchModel); #endregion bool CheckIfValidToEdit(long id); diff --git a/CompanyManagment.App.Contracts/Leave/ILeaveApplication.cs b/CompanyManagment.App.Contracts/Leave/ILeaveApplication.cs index 6a00ddff..209953ff 100644 --- a/CompanyManagment.App.Contracts/Leave/ILeaveApplication.cs +++ b/CompanyManagment.App.Contracts/Leave/ILeaveApplication.cs @@ -22,7 +22,7 @@ public interface ILeaveApplication #region Vafa - List LastLeaveMain(long workshopId, int pageIndex); + List LastLeaveMain(LeaveSearchModel searchModel); #endregion bool CheckIfValidToEdit(long id); diff --git a/CompanyManagment.App.Contracts/Leave/LeaveSearchModel.cs b/CompanyManagment.App.Contracts/Leave/LeaveSearchModel.cs index 68459d65..39e9cf4e 100644 --- a/CompanyManagment.App.Contracts/Leave/LeaveSearchModel.cs +++ b/CompanyManagment.App.Contracts/Leave/LeaveSearchModel.cs @@ -19,4 +19,5 @@ public class LeaveSearchModel public string Decription { get; set; } public int Year { get; set; } public int Month { get; set; } + public int PageIndex { get; set; } } \ No newline at end of file diff --git a/CompanyManagment.Application/LeaveApplication.cs b/CompanyManagment.Application/LeaveApplication.cs index 1d518e25..21b21a90 100644 --- a/CompanyManagment.Application/LeaveApplication.cs +++ b/CompanyManagment.Application/LeaveApplication.cs @@ -348,8 +348,8 @@ public class LeaveApplication : ILeaveApplication return _leaveRepository.PrintAll(id); } - public List LastLeaveMain(long workshopId, int pageIndex) + public List LastLeaveMain(LeaveSearchModel searchModel) { - return _leaveRepository.LastLeaveMain(workshopId, pageIndex); + return _leaveRepository.LastLeaveMain(searchModel); } } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/LeaveRepository.cs b/CompanyManagment.EFCore/Repository/LeaveRepository.cs index 6013f27a..0826fed0 100644 --- a/CompanyManagment.EFCore/Repository/LeaveRepository.cs +++ b/CompanyManagment.EFCore/Repository/LeaveRepository.cs @@ -265,9 +265,36 @@ public class LeaveRepository : RepositoryBase, ILeaveRepository #region Vafa - public List LastLeaveMain(long workshopId, int pageIndex) + public List LastLeaveMain(LeaveSearchModel searchModel) { - return _context.LeaveList.Where(x => x.WorkshopId == workshopId).Select(item => new LeaveViewModel() + var leaveMainList = _context.LeaveList.Where(x => x.WorkshopId == searchModel.WorkshopId); + + if (searchModel.EmployeeId != 0) + leaveMainList = leaveMainList.Where(x => x.EmployeeId == searchModel.EmployeeId); + + if (searchModel.LeaveType == "paidLeave") + leaveMainList = leaveMainList.Where(x => x.LeaveType == "استحقاقی"); + + if (searchModel.LeaveType == "sickLeave") + leaveMainList = leaveMainList.Where(x => x.LeaveType == "استعلاجی"); + + if (!string.IsNullOrWhiteSpace(searchModel.StartLeave) && !string.IsNullOrWhiteSpace(searchModel.EndLeave)) + { + var start = searchModel.StartLeave.ToGeorgianDateTime(); + var end = searchModel.EndLeave.ToGeorgianDateTime(); + leaveMainList = leaveMainList.Where(x => x.StartLeave >= start && x.EndLeave <= end); + } + else if (searchModel.Year != 0 || searchModel.Month != 0) + { + if (searchModel.Year != 0) + leaveMainList = leaveMainList.Where(x => x.Year == searchModel.Year); + + if (searchModel.Month != 0) + leaveMainList = leaveMainList.Where(x => x.Month == searchModel.Month); + } + + + var leaveList = leaveMainList.Where(x => x.WorkshopId == searchModel.WorkshopId).Select(item => new LeaveViewModel() { Id = item.id, StartLeave = item.StartLeave.ToFarsi(), @@ -286,7 +313,9 @@ public class LeaveRepository : RepositoryBase, ILeaveRepository Month = item.Month, MonthStr = item.Month.ToFarsiMonthByIntNumber(), CreationDate = item.CreationDate, - }).OrderByDescending(x => x.CreationDate).Skip(pageIndex).Take(30).ToList(); + }).OrderByDescending(x => x.CreationDate).Skip(searchModel.PageIndex).Take(30).ToList(); + + return leaveList; } #endregion diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/Leave.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/Leave.cshtml index ff30407b..da93054e 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/Leave.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/Leave.cshtml @@ -862,7 +862,7 @@
-
@@ -997,6 +997,7 @@
+ @*