From afe3a294c96c5267dff35535e152e9eab4548d24 Mon Sep 17 00:00:00 2001 From: SamSys Date: Tue, 21 Jan 2025 16:06:41 +0330 Subject: [PATCH] _employerApplication.InsuranceEmployerByWorkshopId(workshopId) added --- .../empolyerAgg/IEmployerRepository.cs | 8 +++- .../Employer/IEmployerApplication.cs | 6 ++- .../EmployerApplication.cs | 5 +++ .../Repository/EmployerRepository.cs | 29 ++++++++++++++- .../Company/InsuranceList/Index.cshtml.cs | 37 +++++++++++-------- 5 files changed, 67 insertions(+), 18 deletions(-) diff --git a/Company.Domain/empolyerAgg/IEmployerRepository.cs b/Company.Domain/empolyerAgg/IEmployerRepository.cs index 88973019..ed6a4139 100644 --- a/Company.Domain/empolyerAgg/IEmployerRepository.cs +++ b/Company.Domain/empolyerAgg/IEmployerRepository.cs @@ -44,7 +44,13 @@ public interface IEmployerRepository : IRepository OperationResult ActiveAll(long id); List GetAllEmployers(); - #endregion + #endregion + + #region Insurance + + (string employerName, bool isLegal) InsuranceEmployerByWorkshopId(long workshopId); + + #endregion diff --git a/CompanyManagment.App.Contracts/Employer/IEmployerApplication.cs b/CompanyManagment.App.Contracts/Employer/IEmployerApplication.cs index 32e00882..969638b4 100644 --- a/CompanyManagment.App.Contracts/Employer/IEmployerApplication.cs +++ b/CompanyManagment.App.Contracts/Employer/IEmployerApplication.cs @@ -44,8 +44,12 @@ public interface IEmployerApplication OperationResult ActiveAll(long id); List GetAllEmployers(); - #endregion + #endregion + #region Insurance + (string employerName, bool isLegal) InsuranceEmployerByWorkshopId(long workshopId); + + #endregion } \ No newline at end of file diff --git a/CompanyManagment.Application/EmployerApplication.cs b/CompanyManagment.Application/EmployerApplication.cs index d3498c57..b7181c51 100644 --- a/CompanyManagment.Application/EmployerApplication.cs +++ b/CompanyManagment.Application/EmployerApplication.cs @@ -939,5 +939,10 @@ public class EmployerApplication : IEmployerApplication return _EmployerRepository.GetAllEmployers(); } + public (string employerName, bool isLegal) InsuranceEmployerByWorkshopId(long workshopId) + { + return _EmployerRepository.InsuranceEmployerByWorkshopId(workshopId); + } + #endregion } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/EmployerRepository.cs b/CompanyManagment.EFCore/Repository/EmployerRepository.cs index 45db0b5a..c180e35f 100644 --- a/CompanyManagment.EFCore/Repository/EmployerRepository.cs +++ b/CompanyManagment.EFCore/Repository/EmployerRepository.cs @@ -724,5 +724,32 @@ public class EmployerRepository : RepositoryBase, IEmployerRepos IsLegal = x.IsLegal, }).ToList(); } - #endregion + #endregion + + #region Insurance + + /// + /// نام کارفرما + /// وضعیت حقیقی حقوقی + /// + /// + /// + public (string employerName, bool isLegal) InsuranceEmployerByWorkshopId(long workshopId) + { + var res = _context.WorkshopEmployers.Where(x => x.WorkshopId == workshopId) + .Include(x => x.Employer).Select(x => new EmprViewModel + { + EmployerFullName = x.Employer.IsLegal == "حقوقی" ? + (x.Employer.EmployerLName != "#" ? x.Employer.FName + " " + x.Employer.EmployerLName: x.Employer.LName) : x.Employer.FullName, + IsLegal = x.Employer.IsLegal, + }).FirstOrDefault(); + + + string employer = res.EmployerFullName; + bool isLegal = res.IsLegal == "حقوقی"; + + return (employer,isLegal); + } + + #endregion } \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs index 15bfc555..ccfa0aa7 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs @@ -143,31 +143,38 @@ public class IndexModel : PageModel //} return new JsonResult(result); } - + /// + /// دریافت اطلاعات کارگاه وکارفرما برای نمایش در مودال ایجاد بیمه + /// + /// + /// public IActionResult OnPostGetEmployerName(int workshopId) { - var names = ""; - var employerList = _employerApplication.GetEmployerByWorkshopId(workshopId); + //var names = ""; + //var employerList = _employerApplication.GetEmployerByWorkshopId(workshopId); var workshopInfo = _insuranceWorkshopInfoApplication.GetDetails(workshopId); - // var personelInfo = _employeeApplication.(workshopId); + var employer = _employerApplication.InsuranceEmployerByWorkshopId(workshopId); + //// var personelInfo = _employeeApplication.(workshopId); - var isLegal = employerList.FirstOrDefault().IsLegal; - var boolIsLegal = isLegal == "حقوقی" ? true : false; + //var isLegal = employerList.FirstOrDefault().IsLegal; + //var boolIsLegal = isLegal == "حقوقی" ? true : false; + + //foreach (var item in employerList) + // if (boolIsLegal) + // names = item.EmployerLName != "#" ? item.FName + " " + item.EmployerLName : item.LName; + // else + // names = names + item.EmployerFullName + ","; + + //if (!boolIsLegal) + // names = names.Substring(0, names.Length - 1); - foreach (var item in employerList) - if (boolIsLegal) - names = item.EmployerLName != "#" ? item.FName + " " + item.EmployerLName : item.LName; - else - names = names + item.EmployerFullName + ","; - if (!boolIsLegal) - names = names.Substring(0, names.Length - 1); return new JsonResult(new { - EmployerNames = names, + EmployerNames = employer.employerName, WorkshopInfo = workshopInfo, - IsLegal = boolIsLegal + IsLegal = employer.isLegal }); }