From 16427f5435c8efb5aa1a43e150fa9dd938b5b029 Mon Sep 17 00:00:00 2001 From: SamSys Date: Fri, 2 Aug 2024 19:48:09 +0330 Subject: [PATCH] Fisxd Lost codes 1 --- .../Account/AccountViewModel.cs | 1 + .../AccountApplication.cs | 41 +- .../Repository/AccountRepository.cs | 3 +- .../WorkshopAgg/IWorkshopRepository.cs | 4 + .../Workshop/IWorkshopApplication.cs | 4 + .../Workshop/PrintListWorkshop.cs | 74 +++ .../Workshop/WorkshopSearchModel.cs | 4 +- .../WorkshopAppliction.cs | 5 + .../Repository/WorkshopRepository.cs | 402 ++++++++++---- .../Pages/Accounts/Account/Index.cshtml.cs | 38 ++ .../Pages/Company/Workshops/Index.cshtml.cs | 52 +- ServiceHost/Pages/Index.cshtml | 65 +++ ServiceHost/Pages/Index.cshtml.cs | 508 +++++++++--------- ServiceHost/Pages/Shared/_Layout.cshtml | 2 - 14 files changed, 808 insertions(+), 395 deletions(-) create mode 100644 CompanyManagment.App.Contracts/Workshop/PrintListWorkshop.cs diff --git a/AccountManagement.Application.Contracts/Account/AccountViewModel.cs b/AccountManagement.Application.Contracts/Account/AccountViewModel.cs index 3b67b685..f023b884 100644 --- a/AccountManagement.Application.Contracts/Account/AccountViewModel.cs +++ b/AccountManagement.Application.Contracts/Account/AccountViewModel.cs @@ -22,5 +22,6 @@ namespace AccountManagement.Application.Contracts.Account public int PositionValue { get; set; } public long PositionId { get; set; } #endregion + public string AdminAreaPermission { get; set; } } } diff --git a/AccountManagement.Application/AccountApplication.cs b/AccountManagement.Application/AccountApplication.cs index 1b6fd30d..be8bbc3f 100644 --- a/AccountManagement.Application/AccountApplication.cs +++ b/AccountManagement.Application/AccountApplication.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using _0_Framework.Application; using AccountManagement.Application.Contracts.Account; using AccountManagement.Domain.AccountAgg; @@ -416,20 +417,36 @@ public class AccountApplication : IAccountApplication public AccountLeftWorkViewModel WorkshopList(long accountId) { - string fullName = _accountRepository.GetById(accountId).Fullname; - var list =_accountLeftworkRepository.WorkshopList(accountId); - var lefts = _accountLeftworkRepository.GetByAccountId(accountId); - var result = new AccountLeftWorkViewModel - { -AccountId = accountId, - AccountFullName = fullName, - StartDateFa = lefts.StartWorkFa, - LeftDateFa = lefts.LeftWorkFa, - WorkshopAccountlist = list, - }; + string fullname = this._accountRepository.GetById(accountId).Fullname; + List source = this._accountLeftworkRepository.WorkshopList(accountId); + List userWorkshopIds = source.Select((Func)(x => x.WorkshopId)).ToList(); + List allWorkshops = this._accountLeftworkRepository.GetAllWorkshops(); + List accountSelectList = this._accountRepository.GetAdminAccountSelectList(); + (string StartWorkFa, string LeftWorkFa) byAccountId = this._accountLeftworkRepository.GetByAccountId(accountId); + return new AccountLeftWorkViewModel() + { + AccountId = accountId, + AccountFullName = fullname, + StartDateFa = byAccountId.StartWorkFa, + LeftDateFa = byAccountId.LeftWorkFa, + WorkshopAccountlist = source, + WorkshopSelectList = new SelectList((IEnumerable)allWorkshops.Where((Func)(x => !userWorkshopIds.Contains(x.Id))), "Id", "WorkshopFullName"), + AccountSelectList = new SelectList((IEnumerable)accountSelectList, "Id", "Fullname") + }; + } - return result; + public OperationResult SaveWorkshopAccount( + List workshopAccountList, + string startDate, + string leftDate, + long accountId) + { + return this._accountLeftworkRepository.SaveWorkshopAccount(workshopAccountList, startDate, leftDate, accountId); + } + public OperationResult CreateNewWorkshopAccount(long currentAccountId, long newAccountId) + { + return this._accountLeftworkRepository.CopyWorkshopToNewAccount(currentAccountId, newAccountId); } public List AccountsForAssign(long accountId) diff --git a/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs index df1839c3..0ffa6c33 100644 --- a/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs +++ b/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs @@ -88,7 +88,8 @@ public class AccountRepository : RepositoryBase, IAccountReposito RoleId = x.RoleId, Mobile = x.Mobile, CreationDateGr = x.CreationDate, - IsActiveString = x.IsActiveString + IsActiveString = x.IsActiveString, + AdminAreaPermission = x.AdminAreaPermission }).ToList(); } diff --git a/Company.Domain/WorkshopAgg/IWorkshopRepository.cs b/Company.Domain/WorkshopAgg/IWorkshopRepository.cs index 43fe0088..f4af714a 100644 --- a/Company.Domain/WorkshopAgg/IWorkshopRepository.cs +++ b/Company.Domain/WorkshopAgg/IWorkshopRepository.cs @@ -53,6 +53,10 @@ public interface IWorkshopRepository : IRepository #endregion + #region Vafa + List PrintWorkshopList(WorkshopSearchModel searchModel); + + #endregion } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/Workshop/IWorkshopApplication.cs b/CompanyManagment.App.Contracts/Workshop/IWorkshopApplication.cs index 2702d5d2..061c8cc8 100644 --- a/CompanyManagment.App.Contracts/Workshop/IWorkshopApplication.cs +++ b/CompanyManagment.App.Contracts/Workshop/IWorkshopApplication.cs @@ -52,5 +52,9 @@ public interface IWorkshopApplication #endregion + #region Vafa + List PrintWorkshopList(WorkshopSearchModel searchModel); + + #endregion } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/Workshop/PrintListWorkshop.cs b/CompanyManagment.App.Contracts/Workshop/PrintListWorkshop.cs new file mode 100644 index 00000000..0f0434c2 --- /dev/null +++ b/CompanyManagment.App.Contracts/Workshop/PrintListWorkshop.cs @@ -0,0 +1,74 @@ +using CompanyManagment.App.Contracts.Employee; +using CompanyManagment.App.Contracts.Employer; +using CompanyManagment.App.Contracts.LeftWork; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using AccountManagement.Application.Contracts.Account; + +namespace CompanyManagment.App.Contracts.Workshop; +public class PrintListWorkshop +{ + public long Id { get; set; } + public string WorkshopName { get; set; } + public string WorkshopSureName { get; set; } + public string WorkshopFullName { get; set; } + public string InsuranceCode { get; set; } + + public string EmployerName { get; set; } + + public string TypeOfOwnership { get; set; } + + public string ArchiveCode { get; set; } + + public string AgentName { get; set; } + + public string AgentPhone { get; set; } + + public string State { get; set; } + + public string City { get; set; } + + public string Address { get; set; } + + public string TypeOfInsuranceSend { get; set; } + + public string TypeOfContract { get; set; } + public long EmpId { get; set; } + public string ContractTerm { get; set; } + public string IsActiveString { get; set; } + public string AgreementNumber { get; set; } + public bool FixedSalary { get; set; } + public string Population { get; set; } + public long? InsuranceJobId { get; set; } + public string ZoneName { get; set; } + public string SearchResultTitle { get; set; } + public bool TotalPaymentHide { get; set; } + public bool HasLeftwork { get; set; } + public bool HasBlockContractingParty { get; set; } + public bool IsClassified { get; set; } + public List EmpList { get; set; } + public List EmployeeList { get; set; } + public List ContractLeftWorks { get; set; } + public List CheckoutLeftWorks { get; set; } + public long ContractingPartId { get; set; } + public int PersonnelCount { get; set; } + //نحوه محاسبه مزد مرخصی + public string ComputeOptions { get; set; } + //نحوه محاسبه عیدی + public string BonusesOptions { get; set; } + + //نحوه محاسبه سنوات + public string YearsOptions { get; set; } + //نگهدارنده وضعیت قراردادهای گذشته + public bool IsOldContract { get; set; } + + #region Vafa + + public List AccountsFullName { get; set; } + public string AccountFullName { get; set; } + + #endregion +} diff --git a/CompanyManagment.App.Contracts/Workshop/WorkshopSearchModel.cs b/CompanyManagment.App.Contracts/Workshop/WorkshopSearchModel.cs index dda1b3ff..586eb051 100644 --- a/CompanyManagment.App.Contracts/Workshop/WorkshopSearchModel.cs +++ b/CompanyManagment.App.Contracts/Workshop/WorkshopSearchModel.cs @@ -43,5 +43,7 @@ public class WorkshopSearchModel //نگهدارنده وضعیت قراردادهای گذشته public bool IsOldContract { get; set; } public List Employers { get; set; } - + public List AccountIds { get; set; } + public long AccountId { get; set; } + } \ No newline at end of file diff --git a/CompanyManagment.Application/WorkshopAppliction.cs b/CompanyManagment.Application/WorkshopAppliction.cs index a00d3402..b73f66c4 100644 --- a/CompanyManagment.Application/WorkshopAppliction.cs +++ b/CompanyManagment.Application/WorkshopAppliction.cs @@ -619,6 +619,11 @@ public class WorkshopAppliction : IWorkshopApplication return _workshopRepository.ActiveAll(id); } + public List PrintWorkshopList(WorkshopSearchModel searchModel) + { + return _workshopRepository.PrintWorkshopList(searchModel); + } + //public List GetConnectedPersonnelsForMain(long workshopId) //{ // return _workshopRepository.GetConnectedPersonnelsForMain(workshopId); diff --git a/CompanyManagment.EFCore/Repository/WorkshopRepository.cs b/CompanyManagment.EFCore/Repository/WorkshopRepository.cs index b0f9ac63..874e5b51 100644 --- a/CompanyManagment.EFCore/Repository/WorkshopRepository.cs +++ b/CompanyManagment.EFCore/Repository/WorkshopRepository.cs @@ -4,6 +4,7 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using _0_Framework.Application; using _0_Framework.InfraStructure; +using AccountManagement.Application.Contracts.Account; using AccountMangement.Infrastructure.EFCore; using Company.Domain.WorkshopAccountAgg; using Company.Domain.WorkshopAgg; @@ -13,6 +14,8 @@ using CompanyManagment.App.Contracts.Employee; using CompanyManagment.App.Contracts.Employer; using CompanyManagment.App.Contracts.Workshop; using Microsoft.EntityFrameworkCore; +using Microsoft.Identity.Client; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory; namespace CompanyManagment.EFCore.Repository; @@ -22,12 +25,14 @@ public class WorkshopRepository : RepositoryBase SearchForMain(WorkshopSearchModel searchModel) { - var leftWorkInsuranceList = _context.LeftWorkInsuranceList.Select(x => x.WorkshopId).ToList(); - var leftWorkList = _context.LeftWorkList.Select(x => x.WorkshopId).ToList(); - var AcountID = _authHelper.CurrentAccountId(); - var workshopIds = _context.WorkshopAccounts.Where(x => x.AccountId == AcountID).Select(x => x.WorkshopId).ToList(); - var blockContractingPartyIds = _context.PersonalContractingParties.Where(x => x.IsBlock == "true").Select(x=>x.id).ToList(); - var query = _context.Workshops.Include(x => x.WorkshopEmployers) - .Select(x => new WorkshopViewModel - { - Id = x.id, - WorkshopName = x.WorkshopName, - InsuranceCode = x.InsuranceCode, - //EmployerName = x.WorkshopEmployers. - WorkshopSureName = x.WorkshopSureName, - WorkshopFullName = x.WorkshopFullName, - TypeOfOwnership = x.TypeOfOwnership, - ArchiveCode = x.ArchiveCode, - AgentName = x.AgentName, - AgentPhone = x.AgentPhone, - State = x.State, - City = x.City, - Address = x.Address, - TypeOfInsuranceSend = x.TypeOfInsuranceSend, - TypeOfContract = x.TypeOfContract, - IsActiveString = x.IsActiveString, - ContractTerm = x.ContractTerm, - AgreementNumber = x.AgreementNumber, - FixedSalary = x.FixedSalary, - Population = x.Population, - InsuranceJobId = x.InsuranceJobId, - ZoneName = x.ZoneName, - TotalPaymentHide = x.TotalPaymentHide, - HasBlockContractingParty = false, - IsClassified = x.IsClassified, - HasLeftwork = (leftWorkInsuranceList.Contains(x.id) || leftWorkList.Contains(x.id)), - EmpList = x.WorkshopEmployers.Select(y => new EmployerViewModel() - { - Id = y.EmployerId, FullName = y.Employer.FullName,ContractingPartyID = y.Employer.ContractingPartyId - }).ToList(), - }).Where(e => workshopIds.Contains(e.Id)); - if (!string.IsNullOrWhiteSpace(searchModel.WorkshopName)) - query = query.Where(x => x.WorkshopName.Contains(searchModel.WorkshopName)); + var leftWorkInsuranceList = _context.LeftWorkInsuranceList.Select(x => x.WorkshopId).ToList(); + var leftWorkList = _context.LeftWorkList.Select(x => x.WorkshopId).ToList(); + var AcountID = _authHelper.CurrentAccountId(); + var workshopIds = _context.WorkshopAccounts.Where(x => x.AccountId == AcountID).ToList(); - if (!string.IsNullOrWhiteSpace(searchModel.InsuranceCode)) - query = query.Where(x => x.InsuranceCode.Contains(searchModel.InsuranceCode)); + if (searchModel.AccountIds != null && searchModel.AccountIds.Any()) + workshopIds = workshopIds.Where(x => searchModel.AccountIds.Contains(x.AccountId)).ToList(); - if (!string.IsNullOrWhiteSpace(searchModel.ArchiveCode)) - query = query.Where(x => x.ArchiveCode == searchModel.ArchiveCode); + var blockContractingPartyIds = _context.PersonalContractingParties.Where(x => x.IsBlock == "true").Select(x => x.id).ToList(); + var query = _context.Workshops.Include(x => x.WorkshopEmployers) + .Select(x => new WorkshopViewModel + { + Id = x.id, + WorkshopName = x.WorkshopName, + InsuranceCode = x.InsuranceCode, + //EmployerName = x.WorkshopEmployers. + WorkshopSureName = x.WorkshopSureName, + WorkshopFullName = x.WorkshopFullName, + TypeOfOwnership = x.TypeOfOwnership, + ArchiveCode = x.ArchiveCode, + AgentName = x.AgentName, + AgentPhone = x.AgentPhone, + State = x.State, + City = x.City, + Address = x.Address, + TypeOfInsuranceSend = x.TypeOfInsuranceSend, + TypeOfContract = x.TypeOfContract, + IsActiveString = x.IsActiveString, + ContractTerm = x.ContractTerm, + AgreementNumber = x.AgreementNumber, + FixedSalary = x.FixedSalary, + Population = x.Population, + InsuranceJobId = x.InsuranceJobId, + ZoneName = x.ZoneName, + TotalPaymentHide = x.TotalPaymentHide, + HasBlockContractingParty = false, + IsClassified = x.IsClassified, + HasLeftwork = (leftWorkInsuranceList.Contains(x.id) || leftWorkList.Contains(x.id)), + EmpList = x.WorkshopEmployers.Select(y => new EmployerViewModel() + { + Id = y.EmployerId, + FullName = y.Employer.FullName, + ContractingPartyID = y.Employer.ContractingPartyId + }).ToList(), + }).Where(e => workshopIds.Select(a => a.WorkshopId).Contains(e.Id)); + if (searchModel.AccountId > 0) + { + var res = _workshopAccountRepository.GetList(searchModel.AccountId).Select(x => x.WorkshopId).ToList(); + query = query.Where(x => res.Contains(x.Id)); + } + + + + - if (!string.IsNullOrWhiteSpace(searchModel.WorkshopName)) - query = query.Where(x => x.WorkshopName.Contains(searchModel.WorkshopName)); + if (!string.IsNullOrWhiteSpace(searchModel.WorkshopName)) + query = query.Where(x => x.WorkshopName.Contains(searchModel.WorkshopName)); - if (!string.IsNullOrWhiteSpace(searchModel.ContractTerm)) - query = query.Where(x => x.ContractTerm == searchModel.ContractTerm); + if (!string.IsNullOrWhiteSpace(searchModel.InsuranceCode)) + query = query.Where(x => x.InsuranceCode.Contains(searchModel.InsuranceCode)); - if (!string.IsNullOrWhiteSpace(searchModel.TypeOfContract)) - query = query.Where(x => x.TypeOfContract == searchModel.TypeOfContract); + if (!string.IsNullOrWhiteSpace(searchModel.ArchiveCode)) + query = query.Where(x => x.ArchiveCode == searchModel.ArchiveCode); - if (searchModel.EmployerId != 0) - { - var emp = _context.WorkshopEmployers.Where(x => x.EmployerId == searchModel.EmployerId) - .Select(x => x.WorkshopId).ToList(); - query = query.Where(x => emp.Contains(x.Id)); + if (!string.IsNullOrWhiteSpace(searchModel.WorkshopName)) + query = query.Where(x => x.WorkshopName.Contains(searchModel.WorkshopName)); - } + if (!string.IsNullOrWhiteSpace(searchModel.ContractTerm)) + query = query.Where(x => x.ContractTerm == searchModel.ContractTerm); - #region NewByHeydari - if (!string.IsNullOrEmpty(searchModel.EmployerLName)) - { - var employerIds = _context.Employers.Where(x => - (!string.IsNullOrEmpty(x.FName) && x.FName.Contains(searchModel.EmployerLName)) || - (!string.IsNullOrEmpty(x.LName) && x.LName.Contains(searchModel.EmployerLName))).Select(x => x.id); - var workshopIds2 = _context.WorkshopEmployers.Where(x => employerIds.Contains(x.EmployerId)).Select(x => x.WorkshopId).ToList(); + if (!string.IsNullOrWhiteSpace(searchModel.TypeOfContract)) + query = query.Where(x => x.TypeOfContract == searchModel.TypeOfContract); - query = query.Where(x => workshopIds2.Contains(x.Id)); - } + if (searchModel.EmployerId != 0) + { + var emp = _context.WorkshopEmployers.Where(x => x.EmployerId == searchModel.EmployerId) + .Select(x => x.WorkshopId).ToList(); + query = query.Where(x => emp.Contains(x.Id)); - if (!string.IsNullOrEmpty(searchModel.State)) - { - query = query.Where(x => x.State == searchModel.State); - } - if (!string.IsNullOrEmpty(searchModel.City)) - { - query = query.Where(x => x.City == searchModel.City); - } - if (!string.IsNullOrWhiteSpace(searchModel.WorkshopFullName)) - query = query.Where(x => x.WorkshopFullName.Contains(searchModel.WorkshopFullName) || x.ArchiveCode.Contains(searchModel.WorkshopFullName)); - #endregion + } - if (searchModel.Id != 0) - query = query.Where(x => x.Id == searchModel.Id); + #region NewByHeydari + if (!string.IsNullOrEmpty(searchModel.EmployerLName)) + { + var employerIds = _context.Employers.Where(x => + (!string.IsNullOrEmpty(x.FName) && x.FName.Contains(searchModel.EmployerLName)) || + (!string.IsNullOrEmpty(x.LName) && x.LName.Contains(searchModel.EmployerLName))).Select(x => x.id); + var workshopIds2 = _context.WorkshopEmployers.Where(x => employerIds.Contains(x.EmployerId)).Select(x => x.WorkshopId).ToList(); - if (searchModel.IsActiveString == null) - { - query = query.Where(x => x.IsActiveString == "true"); - } + query = query.Where(x => workshopIds2.Contains(x.Id)); + } - if (searchModel.IsActiveString == "false") - { - query = query.Where(x => x.IsActiveString == "false"); - } - else if (searchModel.IsActiveString == "both") - { - query = query.Where(x => x.IsActiveString == "false" || x.IsActiveString == "true"); - } + if (!string.IsNullOrEmpty(searchModel.State)) + { + query = query.Where(x => x.State == searchModel.State); + } + if (!string.IsNullOrEmpty(searchModel.City)) + { + query = query.Where(x => x.City == searchModel.City); + } + if (!string.IsNullOrWhiteSpace(searchModel.WorkshopFullName)) + query = query.Where(x => x.WorkshopFullName.Contains(searchModel.WorkshopFullName) || x.ArchiveCode.Contains(searchModel.WorkshopFullName)); + #endregion - var list = query.OrderByDescending(x => x.Id).ToList(); - foreach (var item in list) - { - var empContractingPartyIds = item.EmpList.Select(x => x.ContractingPartyID).ToList(); - item.HasBlockContractingParty = blockContractingPartyIds.Intersect(empContractingPartyIds).Any(); - - } + if (searchModel.Id != 0) + query = query.Where(x => x.Id == searchModel.Id); - return list; - } + if (searchModel.IsActiveString == null) + { + query = query.Where(x => x.IsActiveString == "true"); + } + + if (searchModel.IsActiveString == "false") + { + query = query.Where(x => x.IsActiveString == "false"); + } + else if (searchModel.IsActiveString == "both") + { + query = query.Where(x => x.IsActiveString == "false" || x.IsActiveString == "true"); + } + + var list = query.OrderByDescending(x => x.Id).ToList(); + foreach (var item in list) + { + var empContractingPartyIds = item.EmpList.Select(x => x.ContractingPartyID).ToList(); + item.HasBlockContractingParty = blockContractingPartyIds.Intersect(empContractingPartyIds).Any(); + } + + + return list; + } public OperationResult DeActiveAll(long id) { @@ -1261,5 +1282,182 @@ public class WorkshopRepository : RepositoryBase PrintWorkshopList(WorkshopSearchModel searchModel) + { + var leftWorkInsuranceList = _context.LeftWorkInsuranceList.Select(x => x.WorkshopId).ToList(); + var leftWorkList = _context.LeftWorkList.Select(x => x.WorkshopId).ToList(); + var AcountID = _authHelper.CurrentAccountId(); + var workshopIds = _context.WorkshopAccounts.Where(x => x.AccountId == AcountID).ToList(); + + if (searchModel.AccountIds != null && searchModel.AccountIds.Any()) + workshopIds = workshopIds.Where(x => searchModel.AccountIds.Contains(x.AccountId)).ToList(); + + var blockContractingPartyIds = _context.PersonalContractingParties.Where(x => x.IsBlock == "true").Select(x => x.id).ToList(); + var query = _context.Workshops.Include(x => x.WorkshopEmployers) + .Select(x => new WorkshopViewModel + { + Id = x.id, + WorkshopName = x.WorkshopName, + InsuranceCode = x.InsuranceCode, + //EmployerName = x.WorkshopEmployers. + WorkshopSureName = x.WorkshopSureName, + WorkshopFullName = x.WorkshopFullName, + TypeOfOwnership = x.TypeOfOwnership, + ArchiveCode = x.ArchiveCode, + AgentName = x.AgentName, + AgentPhone = x.AgentPhone, + State = x.State, + City = x.City, + Address = x.Address, + TypeOfInsuranceSend = x.TypeOfInsuranceSend, + TypeOfContract = x.TypeOfContract, + IsActiveString = x.IsActiveString, + ContractTerm = x.ContractTerm, + AgreementNumber = x.AgreementNumber, + FixedSalary = x.FixedSalary, + Population = x.Population, + InsuranceJobId = x.InsuranceJobId, + ZoneName = x.ZoneName, + TotalPaymentHide = x.TotalPaymentHide, + HasBlockContractingParty = false, + IsClassified = x.IsClassified, + HasLeftwork = (leftWorkInsuranceList.Contains(x.id) || leftWorkList.Contains(x.id)), + EmpList = x.WorkshopEmployers.Select(y => new EmployerViewModel() + { + Id = y.EmployerId, + FullName = y.Employer.FullName, + ContractingPartyID = y.Employer.ContractingPartyId + }).ToList(), + }).Where(e => workshopIds.Select(a => a.WorkshopId).Contains(e.Id)); + if (searchModel.AccountId > 0) + { + var res = _workshopAccountRepository.GetList(searchModel.AccountId).Select(x => x.WorkshopId).ToList(); + query = query.Where(x => res.Contains(x.Id)); + } + + + if (!string.IsNullOrWhiteSpace(searchModel.WorkshopName)) + query = query.Where(x => x.WorkshopName.Contains(searchModel.WorkshopName)); + + if (!string.IsNullOrWhiteSpace(searchModel.InsuranceCode)) + query = query.Where(x => x.InsuranceCode.Contains(searchModel.InsuranceCode)); + + if (!string.IsNullOrWhiteSpace(searchModel.ArchiveCode)) + query = query.Where(x => x.ArchiveCode == searchModel.ArchiveCode); + + if (!string.IsNullOrWhiteSpace(searchModel.WorkshopName)) + query = query.Where(x => x.WorkshopName.Contains(searchModel.WorkshopName)); + + if (!string.IsNullOrWhiteSpace(searchModel.ContractTerm)) + query = query.Where(x => x.ContractTerm == searchModel.ContractTerm); + + if (!string.IsNullOrWhiteSpace(searchModel.TypeOfContract)) + query = query.Where(x => x.TypeOfContract == searchModel.TypeOfContract); + + if (searchModel.EmployerId != 0) + { + var emp = _context.WorkshopEmployers.Where(x => x.EmployerId == searchModel.EmployerId) + .Select(x => x.WorkshopId).ToList(); + query = query.Where(x => emp.Contains(x.Id)); + + } + + #region NewByHeydari + if (!string.IsNullOrEmpty(searchModel.EmployerLName)) + { + var employerIds = _context.Employers.Where(x => + (!string.IsNullOrEmpty(x.FName) && x.FName.Contains(searchModel.EmployerLName)) || + (!string.IsNullOrEmpty(x.LName) && x.LName.Contains(searchModel.EmployerLName))).Select(x => x.id); + var workshopIds2 = _context.WorkshopEmployers.Where(x => employerIds.Contains(x.EmployerId)).Select(x => x.WorkshopId).ToList(); + + query = query.Where(x => workshopIds2.Contains(x.Id)); + } + + if (!string.IsNullOrEmpty(searchModel.State)) + { + query = query.Where(x => x.State == searchModel.State); + } + if (!string.IsNullOrEmpty(searchModel.City)) + { + query = query.Where(x => x.City == searchModel.City); + } + if (!string.IsNullOrWhiteSpace(searchModel.WorkshopFullName)) + query = query.Where(x => x.WorkshopFullName.Contains(searchModel.WorkshopFullName) || x.ArchiveCode.Contains(searchModel.WorkshopFullName)); + #endregion + + if (searchModel.Id != 0) + query = query.Where(x => x.Id == searchModel.Id); + + if (searchModel.IsActiveString == null) + { + query = query.Where(x => x.IsActiveString == "true"); + } + + if (searchModel.IsActiveString == "false") + { + query = query.Where(x => x.IsActiveString == "false"); + } + else if (searchModel.IsActiveString == "both") + { + query = query.Where(x => x.IsActiveString == "false" || x.IsActiveString == "true"); + } + + var rawList = query.OrderByDescending(x => x.Id).ToList(); + var list = rawList.Select(x => new PrintListWorkshop() + { + Id = x.Id, + WorkshopName = x.WorkshopName, + InsuranceCode = x.InsuranceCode, + WorkshopSureName = x.WorkshopSureName, + WorkshopFullName = x.WorkshopFullName, + TypeOfOwnership = x.TypeOfOwnership, + ArchiveCode = x.ArchiveCode, + AgentName = x.AgentName, + AgentPhone = x.AgentPhone, + State = x.State, + City = x.City, + Address = x.Address, + TypeOfInsuranceSend = x.TypeOfInsuranceSend, + TypeOfContract = x.TypeOfContract, + IsActiveString = x.IsActiveString, + ContractTerm = x.ContractTerm, + AgreementNumber = x.AgreementNumber, + FixedSalary = x.FixedSalary, + Population = x.Population, + InsuranceJobId = x.InsuranceJobId, + ZoneName = x.ZoneName, + TotalPaymentHide = x.TotalPaymentHide, + HasBlockContractingParty = false, + IsClassified = x.IsClassified, + HasLeftwork = x.HasLeftwork, + EmpList = x.EmpList, + AccountFullName = searchModel.AccountId != 0 ? _accountContext.Accounts.FirstOrDefault(oneAc => oneAc.id == searchModel.AccountId)?.Fullname : "", + AccountsFullName = (searchModel.AccountIds != null && searchModel.AccountIds.Any()) + ? _accountContext.Accounts + .Where(ac => searchModel.AccountIds.Contains(ac.id)) + .Select(account => new AccountViewModel + { + Id = account.id, + Fullname = account.Fullname + }).ToList() + : new List(), + }).ToList(); + + + foreach (var item in list) + { + var empContractingPartyIds = item.EmpList.Select(x => x.ContractingPartyID).ToList(); + item.HasBlockContractingParty = blockContractingPartyIds.Intersect(empContractingPartyIds).Any(); + } + + return list; + } + + #endregion } \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Pages/Accounts/Account/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Accounts/Account/Index.cshtml.cs index 5bd41b5a..dce53d05 100644 --- a/ServiceHost/Areas/Admin/Pages/Accounts/Account/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Accounts/Account/Index.cshtml.cs @@ -217,4 +217,42 @@ public class IndexModel : PageModel return Partial("AccountLeftWork", res); } + + public IActionResult OnPostCreateAccountLeftWork( + List workshopAccountlistViewModel, + string startDate, + string leftDate, + long accountId) + { + if (string.IsNullOrWhiteSpace(startDate)) + return (IActionResult)new JsonResult((object)new + { + isSuccess = false, + mess = "تاریخ شروع بکار خالی است" + }); + OperationResult operationResult = this._accountApplication.SaveWorkshopAccount(workshopAccountlistViewModel, startDate, leftDate, accountId); + return operationResult.IsSuccedded ? (IActionResult)new JsonResult((object)new + { + isSuccess = true, + mess = operationResult.Message + }) : (IActionResult)new JsonResult((object)new + { + isSuccess = false, + mess = operationResult.Message + }); + } + + public IActionResult OnGetCopyWorkshopToNewAccount(long currentAccountId, long newAccountId) + { + OperationResult newWorkshopAccount = this._accountApplication.CreateNewWorkshopAccount(currentAccountId, newAccountId); + return newWorkshopAccount.IsSuccedded ? (IActionResult)new JsonResult((object)new + { + isSuccess = true + }) : (IActionResult)new JsonResult((object)new + { + isSuccess = false, + message = newWorkshopAccount.Message + }); + } +} } \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Pages/Company/Workshops/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Company/Workshops/Index.cshtml.cs index 05ed6dcc..90f085d0 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Workshops/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Company/Workshops/Index.cshtml.cs @@ -1,4 +1,5 @@ using _0_Framework.Application; +using AccountManagement.Application.Contracts.Account; using AccountManagement.Domain.AccountAgg; using Company.Domain.empolyerAgg; using Company.Domain.WorkshopAgg; @@ -37,14 +38,17 @@ public class IndexModel : PageModel private readonly IWorkshopRepository _workshopRepository; private readonly IYearlySalaryApplication _yearlySalaryApplication; private readonly IZoneApplication _zoneApplication; - public SelectList Employers; - public string LName; - public WorkshopSearchModel SearchModel; - public string WorkshopFullName; - public SelectList WorkshopList; - public List Workshops; + [TempData] + public string Message { get; set; } + public WorkshopSearchModel SearchModel; + public List Workshops; + public SelectList WorkshopList; + public SelectList Employers; + public string LName; + public string WorkshopFullName; + public List AccountList; - public IndexModel(IWorkshopApplication workshopApplication, IEmployerApplication employerApplication, + public IndexModel(IWorkshopApplication workshopApplication, IEmployerApplication employerApplication, IEmployerRepository employerRepository, IWorkshopRepository workshopRepository, IAccountRepository accountRepository, IZoneApplication zoneApplication, IInsuranceJobApplication insuranceJobApplication, IJobApplication jobApplication, @@ -68,22 +72,34 @@ public class IndexModel : PageModel _yearlySalaryApplication = yearlySalaryApplication; } - [TempData] public string Message { get; set; } + public void OnGet(WorkshopSearchModel searchModel) { - if (string.IsNullOrWhiteSpace(searchModel.EmployerLName) - && string.IsNullOrWhiteSpace(searchModel.WorkshopFullName) - && string.IsNullOrWhiteSpace(searchModel.InsuranceCode)) - Workshops = _workshopApplication.SearchForMain(searchModel) - .OrderByDescending(x => x.HasBlockContractingParty).Take(100).ToList(); - else - Workshops = _workshopApplication.SearchForMain(searchModel) - .OrderByDescending(x => x.HasBlockContractingParty).ToList(); + //if (string.IsNullOrWhiteSpace(searchModel.EmployerLName) + // && string.IsNullOrWhiteSpace(searchModel.WorkshopFullName) + // && string.IsNullOrWhiteSpace(searchModel.InsuranceCode)) + // Workshops = _workshopApplication.SearchForMain(searchModel) + // .OrderByDescending(x => x.HasBlockContractingParty).Take(100).ToList(); + //else + // Workshops = _workshopApplication.SearchForMain(searchModel) + // .OrderByDescending(x => x.HasBlockContractingParty).ToList(); + AccountList = _accountRepository.GetAccounts().Where(x => x.AdminAreaPermission == "true").ToList(); + if (!string.IsNullOrWhiteSpace(searchModel.EmployerLName) + || !string.IsNullOrWhiteSpace(searchModel.WorkshopFullName) + || !string.IsNullOrWhiteSpace(searchModel.InsuranceCode) || searchModel.AccountId > 0) + { + Workshops = _workshopApplication.SearchForMain(searchModel).OrderByDescending(x => x.HasBlockContractingParty == true).ToList(); + } + else + { + Workshops = _workshopApplication.SearchForMain(searchModel).OrderByDescending(x => x.HasBlockContractingParty == true).Take(100).ToList(); - //-----employer----- - if (searchModel.EmployerId > 0) + } + + //-----employer----- + if (searchModel.EmployerId > 0) { var employer = _EmployerApplication.GetDetails(searchModel.EmployerId); LName = employer.IsLegal == "حقیقی" ? employer.FName + " " + employer.LName : employer.LName; diff --git a/ServiceHost/Pages/Index.cshtml b/ServiceHost/Pages/Index.cshtml index 41f01388..ab8c8ab1 100644 --- a/ServiceHost/Pages/Index.cshtml +++ b/ServiceHost/Pages/Index.cshtml @@ -294,7 +294,72 @@ @section Script{ +