diff --git a/AccountManagement.Application.Contracts/Account/AccountSelectListViewModel.cs b/AccountManagement.Application.Contracts/Account/AccountSelectListViewModel.cs index 8328e99f..bc1a5098 100644 --- a/AccountManagement.Application.Contracts/Account/AccountSelectListViewModel.cs +++ b/AccountManagement.Application.Contracts/Account/AccountSelectListViewModel.cs @@ -4,4 +4,6 @@ public class AccountSelectListViewModel { public long Id { get; set; } public string Name { get; set; } + + public long RoleId { get; set; } } \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs index d603c246..1947a65b 100644 --- a/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs +++ b/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs @@ -318,7 +318,8 @@ public class AccountRepository : RepositoryBase, IAccountReposito return await _context.Accounts.Where(x => x.AdminAreaPermission == "true").Select(x => new AccountSelectListViewModel() { Id = x.id, - Name = x.Fullname + Name = x.Fullname, + RoleId = x.RoleId }).ToListAsync(); } diff --git a/CompanyManagment.EFCore/Repository/AdminMonthlyOverviewRepository.cs b/CompanyManagment.EFCore/Repository/AdminMonthlyOverviewRepository.cs index 62e0544c..cdc86d40 100644 --- a/CompanyManagment.EFCore/Repository/AdminMonthlyOverviewRepository.cs +++ b/CompanyManagment.EFCore/Repository/AdminMonthlyOverviewRepository.cs @@ -46,18 +46,30 @@ public class AdminMonthlyOverviewRepository : RepositoryBase c.ContractStartGr <= targetDate && c.ContractEndGr >= targetDate && c.IsActiveString == "true") + .Where(c => c.ContractStartGr <= targetDate && c.ContractEndGr >= targetDate ) .Select(c => c.ContractingPartyId); // دریافت کارگاه‌های مرتبط با اکانت - var workshopAccounts = _companyContext.WorkshopAccounts - .AsNoTracking() - .Where(w => w.AccountId == accountId) - .Select(w => w.WorkshopId); + List workshopAccounts; + if (accountId is 2 or 3) + { + workshopAccounts = _companyContext.WorkshopAccounts + .AsNoTracking() + .Where(w => w.AccountId == accountId) + .Select(w => w.WorkshopId).ToList(); + } + else + { + workshopAccounts = _accountContext.AccountLeftWorks + .AsNoTracking() + .Where(w => w.AccountId == accountId && w.StartWorkGr <= targetDate && w.LeftWorkGr > targetDate) + .Select(w => w.WorkshopId).ToList(); + } - var workshopsHasLeftWorkEmployees = _companyContext.LeftWorkList.Where(x => - (x.StartWorkDate <= targetDate && x.LeftWorkDate.AddDays(-1) >= targetDate) - || (x.StartWorkDate <= nextMonth && x.LeftWorkDate.AddDays(-1) >= nextMonth)&& workshopAccounts.Contains(x.WorkshopId)).Select(x=>x.WorkshopId); + + var workshopsHasLeftWorkEmployees = _companyContext.LeftWorkList.Where(x => + ((x.StartWorkDate <= targetDate && x.LeftWorkDate.AddDays(-1) >= targetDate) + || (x.StartWorkDate <= nextMonth && x.LeftWorkDate.AddDays(-1) >= nextMonth)) && workshopAccounts.Contains(x.WorkshopId)).Select(x => x.WorkshopId); @@ -66,7 +78,7 @@ public class AdminMonthlyOverviewRepository : RepositoryBase workshopsHasLeftWorkEmployees.Contains(w.id)) + .Where(w => workshopsHasLeftWorkEmployees.Contains(w.id) && w.IsActive) .Include(w => w.WorkshopEmployers) .ThenInclude(we => we.Employer) .ThenInclude(e => e.ContractingParty).AsSplitQuery(). @@ -86,7 +98,7 @@ public class AdminMonthlyOverviewRepository : RepositoryBase x.Workshop.id).ToList(); - + // پیدا کردن کارگاه‌هایی که قبلاً برای این ماه/سال AdminMonthlyOverview دارند var adminMonthlyOverviewWorkshopIds = await _companyContext.AdminMonthlyOverviews .AsNoTracking() @@ -110,7 +122,7 @@ public class AdminMonthlyOverviewRepository : RepositoryBase x.ContractingParty?.IsBlock == isBlock).ToList(); @@ -161,7 +173,7 @@ public class AdminMonthlyOverviewRepository : RepositoryBase x.IsBlock).ThenBy(x=>x.WorkshopArchiveCodeInt).ToList(); + }).OrderBy(x => x.IsBlock).ThenBy(x => x.WorkshopArchiveCodeInt).ToList(); return adminMonthlyOverviewList; @@ -235,7 +247,7 @@ public class AdminMonthlyOverviewRepository : RepositoryBase x.WorkshopId).ToList(); - + var workingContractGrouping = workingContractEmployeeIds.GroupBy(x => x.WorkshopId).Select(x => new { WorkshopId = x.Key, diff --git a/CompanyManagment.EFCore/Repository/ReportRepository.cs b/CompanyManagment.EFCore/Repository/ReportRepository.cs index 3a0810dd..85b5924e 100644 --- a/CompanyManagment.EFCore/Repository/ReportRepository.cs +++ b/CompanyManagment.EFCore/Repository/ReportRepository.cs @@ -341,7 +341,7 @@ public class ReportRepository : IReportRepository var allCheckoutToBeTople = allCheckoutLeftworks.Select(x => new { x.EmployeeId, x.WorkshopId }).ToList(); //تمام تصفیه حساب های ایجاد شده ماه مورد نظر var allCheckoutCreated = _context.CheckoutSet - .Where(x => allCheckoutLeftworkEmployeeIds.Contains(x.EmployeeId)) + .Where(x => allCheckoutLeftworkEmployeeIds.Contains(x.EmployeeId) && allCheckoutLeftworkWorkshopIds.Contains(x.WorkshopId)) .Where(x => x.ContractStart.Date >= currentMonthStart.Date && x.ContractEnd.Date <= currentMonthEnd.Date && x.IsActiveString == "true"); @@ -404,7 +404,7 @@ public class ReportRepository : IReportRepository var allContracToBeTople = allContractLeftworks.Select(x => new { x.EmployeeId, x.WorkshopId }).ToList(); var allContractLeftworkWorkshopIds = allContractLeftworks.Select(x => x.WorkshopId).ToList(); var allContractCreated = _context.Contracts - .Where(x => allContractLeftworkEmployeeIds.Contains(x.EmployeeId)) + .Where(x => allContractLeftworkEmployeeIds.Contains(x.EmployeeId) && allContractLeftworkWorkshopIds.Contains(x.WorkshopIds)) .Where(x => x.ContarctStart.Date <= nextMonthEnd.Date && x.ContractEnd.Date > nextMonthStart.Date && x.IsActiveString == "true"); var allContractCreatedlist = allContractCreated.Select(x => x.WorkshopIds).ToList(); diff --git a/ServiceHost/Areas/Admin/Pages/Accounts/Account/EditRole.cshtml b/ServiceHost/Areas/Admin/Pages/Accounts/Account/EditRole.cshtml index 87befb4b..e25f3652 100644 --- a/ServiceHost/Areas/Admin/Pages/Accounts/Account/EditRole.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Accounts/Account/EditRole.cshtml @@ -838,6 +838,25 @@ + +
+ + + + +
+ + +
+ + + + +
@*