Compare commits
5 Commits
Feature/fi
...
Feature/Cl
| Author | SHA1 | Date | |
|---|---|---|---|
| 4ed1907075 | |||
| efcf40eea8 | |||
|
|
d2acf59eba | ||
|
|
3139552217 | ||
|
|
dc4c8e9a26 |
@@ -54,6 +54,7 @@ public interface IEmployeeRepository : IRepository<long, Employee>
|
|||||||
|
|
||||||
Employee GetIgnoreQueryFilter(long id);
|
Employee GetIgnoreQueryFilter(long id);
|
||||||
|
|
||||||
|
[Obsolete("این متد منسوخ شده است و از متد WorkedEmployeesInWorkshopSelectList استفاده کنید")]
|
||||||
Task<List<EmployeeSelectListViewModel>> WorkedEmployeesInWorkshopSelectList(long workshopId);
|
Task<List<EmployeeSelectListViewModel>> WorkedEmployeesInWorkshopSelectList(long workshopId);
|
||||||
|
|
||||||
|
|
||||||
@@ -77,7 +78,32 @@ public interface IEmployeeRepository : IRepository<long, Employee>
|
|||||||
Task<List<EmployeeSelectListViewModel>> GetSelectList(string searchText,long id);
|
Task<List<EmployeeSelectListViewModel>> GetSelectList(string searchText,long id);
|
||||||
Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel);
|
Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel);
|
||||||
Task<List<GetClientEmployeeListViewModel>> GetClientEmployeeList(GetClientEmployeeListSearchModel searchModel, long workshopId);
|
Task<List<GetClientEmployeeListViewModel>> GetClientEmployeeList(GetClientEmployeeListSearchModel searchModel, long workshopId);
|
||||||
#endregion
|
|
||||||
|
/// <summary>
|
||||||
|
/// دریافت لیست پرسنل کلاینت
|
||||||
|
/// api
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="searchModel"></param>
|
||||||
|
/// <param name="workshopId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<EmployeeListDto>> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, long workshopId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// پرینت تجمیعی پرسنل کلاینت
|
||||||
|
/// api
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="workshopId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<PrintAllEmployeesInfoDtoClient>> PrintAllEmployeesInfoClient(long workshopId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// سلکت لیست پرسنل های کارگاه کلاینت
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="workshopId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<EmployeeSelectListViewModel>> GetWorkingEmployeesSelectList(long workshopId);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
using System.Diagnostics.Contracts;
|
||||||
|
|
||||||
|
namespace CompanyManagment.App.Contracts.Employee.DTO;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// لیست پرسنل کلاینت
|
||||||
|
/// api
|
||||||
|
/// </summary>
|
||||||
|
public class EmployeeListDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// آی دی پرسنل
|
||||||
|
/// </summary>
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام کامل پرسنل
|
||||||
|
/// </summary>
|
||||||
|
public string EmployeeFullName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// کد پرسنلی
|
||||||
|
/// </summary>
|
||||||
|
public int PersonnelCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// وضعیت تاهل
|
||||||
|
/// </summary>
|
||||||
|
public string MaritalStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///کد ملی
|
||||||
|
/// </summary>
|
||||||
|
public string NationalCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شماره شناسنامه
|
||||||
|
/// </summary>
|
||||||
|
public string IdNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// تاریخ تولد
|
||||||
|
/// </summary>
|
||||||
|
public string DateOfBirth { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام پدر
|
||||||
|
/// </summary>
|
||||||
|
public string FatherName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// تعداد فرزندان
|
||||||
|
/// </summary>
|
||||||
|
public string NumberOfChildren { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// آخرین تاریخ شروع بکار قرارداد
|
||||||
|
/// </summary>
|
||||||
|
public string LatestContractStartDate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// تاریخ ترک کار قرارداد
|
||||||
|
/// </summary>
|
||||||
|
public string ContractLeftDate { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// آخرین تاریخ شروع بکار بیمه
|
||||||
|
/// </summary>
|
||||||
|
public string LatestInsuranceStartDate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// تاریخ ترک کار بیمه
|
||||||
|
/// </summary>
|
||||||
|
public string InsuranceLeftDate { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// دارای قرارداد است؟
|
||||||
|
/// </summary>
|
||||||
|
public bool HasContract { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// دارای بیمه است؟
|
||||||
|
/// </summary>
|
||||||
|
public bool HasInsurance { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// وضعیت پرسنل در کارگاه
|
||||||
|
/// </summary>
|
||||||
|
public EmployeeStatusInWorkshop EmployeeStatusInWorkshop { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
namespace CompanyManagment.App.Contracts.Employee.DTO;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// سرچ مدل پرسنل
|
||||||
|
/// api
|
||||||
|
/// </summary>
|
||||||
|
public class EmployeeSearchModelDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// نام پرسنل
|
||||||
|
/// </summary>
|
||||||
|
public string EmployeeFullName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// کد ملی
|
||||||
|
/// </summary>
|
||||||
|
public string NationalCode { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
namespace CompanyManagment.App.Contracts.Employee.DTO;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// وضعیت پرسنل در کارگاه
|
||||||
|
/// api
|
||||||
|
/// </summary>
|
||||||
|
public enum EmployeeStatusInWorkshop
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ایجاد شده توسط کارفرما
|
||||||
|
/// </summary>
|
||||||
|
CreatedByClient,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ترک کار موقت
|
||||||
|
/// </summary>
|
||||||
|
LefWorkTemp,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// در حال کار در کارگاه
|
||||||
|
/// </summary>
|
||||||
|
Working,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// قطع ارتباط و ترک کار کامب
|
||||||
|
/// </summary>
|
||||||
|
HasLeft,
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
namespace CompanyManagment.App.Contracts.Employee.DTO;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// پرینت تجمیعی پرسنل
|
||||||
|
/// </summary>
|
||||||
|
public class PrintAllEmployeesInfoDtoClient
|
||||||
|
{
|
||||||
|
public PrintAllEmployeesInfoDtoClient(EmployeeListDto source)
|
||||||
|
{
|
||||||
|
Id = source.Id;
|
||||||
|
EmployeeFullName = source.EmployeeFullName;
|
||||||
|
PersonnelCode = source.PersonnelCode;
|
||||||
|
MaritalStatus = source.MaritalStatus;
|
||||||
|
NationalCode = source.NationalCode;
|
||||||
|
IdNumber = source.IdNumber;
|
||||||
|
DateOfBirth = source.DateOfBirth;
|
||||||
|
FatherName = source.FatherName;
|
||||||
|
NumberOfChildren = source.NumberOfChildren;
|
||||||
|
LatestContractStartDate = source.LatestContractStartDate;
|
||||||
|
ContractLeftDate = source.ContractLeftDate;
|
||||||
|
LatestInsuranceStartDate = source.LatestInsuranceStartDate;
|
||||||
|
InsuranceLeftDate = source.InsuranceLeftDate;
|
||||||
|
EmployeeStatusInWorkshop = source.EmployeeStatusInWorkshop;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// آی دی پرسنل
|
||||||
|
/// </summary>
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام کامل پرسنل
|
||||||
|
/// </summary>
|
||||||
|
public string EmployeeFullName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// کد پرسنلی
|
||||||
|
/// </summary>
|
||||||
|
public int PersonnelCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// وضعیت تاهل
|
||||||
|
/// </summary>
|
||||||
|
public string MaritalStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///کد ملی
|
||||||
|
/// </summary>
|
||||||
|
public string NationalCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شماره شناسنامه
|
||||||
|
/// </summary>
|
||||||
|
public string IdNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// تاریخ تولد
|
||||||
|
/// </summary>
|
||||||
|
public string DateOfBirth { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// نام پدر
|
||||||
|
/// </summary>
|
||||||
|
public string FatherName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// تعداد فرزندان
|
||||||
|
/// </summary>
|
||||||
|
public string NumberOfChildren { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// آخرین تاریخ شروع بکار قرارداد
|
||||||
|
/// </summary>
|
||||||
|
public string LatestContractStartDate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// تاریخ ترک کار قرارداد
|
||||||
|
/// </summary>
|
||||||
|
public string ContractLeftDate { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// آخرین تاریخ شروع بکار بیمه
|
||||||
|
/// </summary>
|
||||||
|
public string LatestInsuranceStartDate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// تاریخ ترک کار بیمه
|
||||||
|
/// </summary>
|
||||||
|
public string InsuranceLeftDate { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// وضعیت پرسنل در کارگاه
|
||||||
|
/// </summary>
|
||||||
|
public EmployeeStatusInWorkshop EmployeeStatusInWorkshop { get; set; }
|
||||||
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using _0_Framework.Application;
|
using _0_Framework.Application;
|
||||||
using CompanyManagment.App.Contracts.Employee.DTO;
|
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||||
using CompanyManagment.App.Contracts.EmployeeInsuranceRecord;
|
using CompanyManagment.App.Contracts.EmployeeInsuranceRecord;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace CompanyManagment.App.Contracts.Employee;
|
namespace CompanyManagment.App.Contracts.Employee;
|
||||||
|
|
||||||
@@ -73,6 +75,7 @@ public interface IEmployeeApplication
|
|||||||
long workshopId);
|
long workshopId);
|
||||||
Task<OperationResult> EditEmployeeInEmployeeDocumentWorkFlow(EditEmployeeInEmployeeDocument command);
|
Task<OperationResult> EditEmployeeInEmployeeDocumentWorkFlow(EditEmployeeInEmployeeDocument command);
|
||||||
|
|
||||||
|
[Obsolete("این متد منسوخ شده است و از متد WorkedEmployeesInWorkshopSelectList استفاده کنید")]
|
||||||
Task<List<EmployeeSelectListViewModel>> WorkedEmployeesInWorkshopSelectList(long workshopId);
|
Task<List<EmployeeSelectListViewModel>> WorkedEmployeesInWorkshopSelectList(long workshopId);
|
||||||
|
|
||||||
Task<OperationResult<EmployeeDataFromApiViewModel>> GetEmployeeDataFromApi(string nationalCode, string birthDate);
|
Task<OperationResult<EmployeeDataFromApiViewModel>> GetEmployeeDataFromApi(string nationalCode, string birthDate);
|
||||||
@@ -103,8 +106,26 @@ public interface IEmployeeApplication
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<GetClientEmployeeListViewModel>> GetClientEmployeeList(GetClientEmployeeListSearchModel searchModel, long workshopId);
|
Task<List<GetClientEmployeeListViewModel>> GetClientEmployeeList(GetClientEmployeeListSearchModel searchModel, long workshopId);
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// دریافت لیست پرسنل کلاینت
|
||||||
|
/// api
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="searchModel"></param>
|
||||||
|
/// <param name="workshopId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<EmployeeListDto>> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, long workshopId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// پرینت تجمیعی پرسنل کلاینت
|
||||||
|
/// api
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="workshopId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<PrintAllEmployeesInfoDtoClient>> PrintAllEmployeesInfoClient(long workshopId);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
Task<List<EmployeeSelectListViewModel>> GetWorkingEmployeesSelectList(long workshopId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetClientEmployeeListSearchModel
|
public class GetClientEmployeeListSearchModel
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
using System.Collections.Generic;
|
using _0_Framework.Application;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using _0_Framework.Application;
|
|
||||||
using AccountManagement.Application.Contracts.Account;
|
using AccountManagement.Application.Contracts.Account;
|
||||||
|
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||||
using CompanyManagment.App.Contracts.Workshop.DTOs;
|
using CompanyManagment.App.Contracts.Workshop.DTOs;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace CompanyManagment.App.Contracts.Workshop;
|
namespace CompanyManagment.App.Contracts.Workshop;
|
||||||
|
|
||||||
@@ -92,6 +93,8 @@ public interface IWorkshopApplication
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
Task<ActionResult<OperationResult>> CreateWorkshopWorkflowRegistration(CreateWorkshopWorkflowRegistration command);
|
Task<ActionResult<OperationResult>> CreateWorkshopWorkflowRegistration(CreateWorkshopWorkflowRegistration command);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CreateWorkshopWorkflowRegistration
|
public class CreateWorkshopWorkflowRegistration
|
||||||
|
|||||||
@@ -1734,5 +1734,20 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
|||||||
return await _EmployeeRepository.GetClientEmployeeList(searchModel, workshopId);
|
return await _EmployeeRepository.GetClientEmployeeList(searchModel, workshopId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<EmployeeListDto>> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, long workshopId)
|
||||||
|
{
|
||||||
|
return await _EmployeeRepository.ListOfAllEmployeesClient(searchModel, workshopId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<PrintAllEmployeesInfoDtoClient>> PrintAllEmployeesInfoClient(long workshopId)
|
||||||
|
{
|
||||||
|
return await _EmployeeRepository.PrintAllEmployeesInfoClient(workshopId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<EmployeeSelectListViewModel>> GetWorkingEmployeesSelectList(long workshopId)
|
||||||
|
{
|
||||||
|
return await _EmployeeRepository.GetWorkingEmployeesSelectList(workshopId);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ using Company.Domain.LeftWorkAgg;
|
|||||||
using Company.Domain.LeftWorkInsuranceAgg;
|
using Company.Domain.LeftWorkInsuranceAgg;
|
||||||
using Company.Domain.WorkshopAgg;
|
using Company.Domain.WorkshopAgg;
|
||||||
using CompanyManagment.App.Contracts.Employee;
|
using CompanyManagment.App.Contracts.Employee;
|
||||||
|
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||||
using CompanyManagment.App.Contracts.EmployeeChildren;
|
using CompanyManagment.App.Contracts.EmployeeChildren;
|
||||||
using CompanyManagment.App.Contracts.LeftWork;
|
using CompanyManagment.App.Contracts.LeftWork;
|
||||||
using CompanyManagment.App.Contracts.RollCallService;
|
using CompanyManagment.App.Contracts.RollCallService;
|
||||||
@@ -1126,5 +1127,6 @@ public class WorkshopAppliction : IWorkshopApplication
|
|||||||
return operation.Succcedded();
|
return operation.Succcedded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -1,23 +1,24 @@
|
|||||||
using System;
|
using _0_Framework.Application;
|
||||||
using System.Collections.Generic;
|
using _0_Framework.Application.Enums;
|
||||||
using System.Data;
|
using _0_Framework.Exceptions;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using _0_Framework.Application;
|
|
||||||
using _0_Framework.InfraStructure;
|
using _0_Framework.InfraStructure;
|
||||||
using Company.Domain.ClientEmployeeWorkshopAgg;
|
using Company.Domain.ClientEmployeeWorkshopAgg;
|
||||||
using Company.Domain.EmployeeAccountAgg;
|
using Company.Domain.EmployeeAccountAgg;
|
||||||
using Company.Domain.EmployeeAgg;
|
using Company.Domain.EmployeeAgg;
|
||||||
using CompanyManagment.App.Contracts.Employee;
|
|
||||||
using Company.Domain.EmployeeInsuranceRecordAgg;
|
using Company.Domain.EmployeeInsuranceRecordAgg;
|
||||||
|
using Company.Domain.InsuranceListAgg;
|
||||||
|
using CompanyManagment.App.Contracts.Employee;
|
||||||
|
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||||
using CompanyManagment.App.Contracts.EmployeeInsuranceRecord;
|
using CompanyManagment.App.Contracts.EmployeeInsuranceRecord;
|
||||||
|
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||||
using Microsoft.Data.SqlClient;
|
using Microsoft.Data.SqlClient;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using CompanyManagment.App.Contracts.Employee.DTO;
|
using System;
|
||||||
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
using System.Collections.Generic;
|
||||||
using _0_Framework.Application.Enums;
|
using System.Data;
|
||||||
using _0_Framework.Exceptions;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace CompanyManagment.EFCore.Repository;
|
namespace CompanyManagment.EFCore.Repository;
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
|||||||
public bool city = true;
|
public bool city = true;
|
||||||
public DateTime initial = new DateTime(1922, 01, 01, 00, 00, 00, 0000000);
|
public DateTime initial = new DateTime(1922, 01, 01, 00, 00, 00, 0000000);
|
||||||
private readonly IAuthHelper _authHelper;
|
private readonly IAuthHelper _authHelper;
|
||||||
public EmployeeRepository(CompanyContext context, IConfiguration configuration, IAuthHelper authHelper) :base(context)
|
public EmployeeRepository(CompanyContext context, IConfiguration configuration, IAuthHelper authHelper) : base(context)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
@@ -42,13 +43,13 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
|||||||
|
|
||||||
public List<EmployeeViewModel> GetEmployee()
|
public List<EmployeeViewModel> GetEmployee()
|
||||||
{
|
{
|
||||||
return _context.Employees.Where(x=>x.IsActive).Select(x => new EmployeeViewModel
|
return _context.Employees.Where(x => x.IsActive).Select(x => new EmployeeViewModel
|
||||||
{
|
{
|
||||||
Id = x.id,
|
Id = x.id,
|
||||||
FName = x.FName,
|
FName = x.FName,
|
||||||
|
|
||||||
LName = x.LName,
|
LName = x.LName,
|
||||||
EmployeeFullName = x.FName +" "+x.LName,
|
EmployeeFullName = x.FName + " " + x.LName,
|
||||||
FatherName = x.FatherName,
|
FatherName = x.FatherName,
|
||||||
NationalCode = x.NationalCode,
|
NationalCode = x.NationalCode,
|
||||||
IdNumber = x.IdNumber,
|
IdNumber = x.IdNumber,
|
||||||
@@ -61,48 +62,48 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
|||||||
public EditEmployee GetDetails(long id)
|
public EditEmployee GetDetails(long id)
|
||||||
{
|
{
|
||||||
return _context.Employees.Select(x => new EditEmployee
|
return _context.Employees.Select(x => new EditEmployee
|
||||||
{
|
{
|
||||||
Id = x.id,
|
Id = x.id,
|
||||||
FName = x.FName,
|
FName = x.FName,
|
||||||
LName = x.LName,
|
LName = x.LName,
|
||||||
Gender = x.Gender,
|
Gender = x.Gender,
|
||||||
NationalCode = x.NationalCode,
|
NationalCode = x.NationalCode,
|
||||||
IdNumber = x.IdNumber,
|
IdNumber = x.IdNumber,
|
||||||
Nationality = x.Nationality,
|
Nationality = x.Nationality,
|
||||||
FatherName = x.FatherName,
|
FatherName = x.FatherName,
|
||||||
DateOfBirth = x.DateOfBirth == initial ? "" : x.DateOfBirth.ToFarsi(),
|
DateOfBirth = x.DateOfBirth == initial ? "" : x.DateOfBirth.ToFarsi(),
|
||||||
DateOfIssue = x.DateOfIssue == initial ? "" : x.DateOfIssue.ToFarsi(),
|
DateOfIssue = x.DateOfIssue == initial ? "" : x.DateOfIssue.ToFarsi(),
|
||||||
PlaceOfIssue = x.PlaceOfIssue,
|
PlaceOfIssue = x.PlaceOfIssue,
|
||||||
Phone = x.Phone,
|
Phone = x.Phone,
|
||||||
Address = x.Address,
|
Address = x.Address,
|
||||||
State = x.State,
|
State = x.State,
|
||||||
City = x.City,
|
City = x.City,
|
||||||
MaritalStatus = x.MaritalStatus,
|
MaritalStatus = x.MaritalStatus,
|
||||||
MilitaryService = x.MilitaryService,
|
MilitaryService = x.MilitaryService,
|
||||||
LevelOfEducation = x.LevelOfEducation,
|
LevelOfEducation = x.LevelOfEducation,
|
||||||
FieldOfStudy = x.FieldOfStudy,
|
FieldOfStudy = x.FieldOfStudy,
|
||||||
BankCardNumber = x.BankCardNumber,
|
BankCardNumber = x.BankCardNumber,
|
||||||
BankBranch = x.BankBranch,
|
BankBranch = x.BankBranch,
|
||||||
InsuranceCode = x.InsuranceCode,
|
InsuranceCode = x.InsuranceCode,
|
||||||
InsuranceHistoryByYear = x.InsuranceHistoryByYear,
|
InsuranceHistoryByYear = x.InsuranceHistoryByYear,
|
||||||
InsuranceHistoryByMonth = x.InsuranceHistoryByMonth,
|
InsuranceHistoryByMonth = x.InsuranceHistoryByMonth,
|
||||||
NumberOfChildren = x.NumberOfChildren,
|
NumberOfChildren = x.NumberOfChildren,
|
||||||
OfficePhone = x.OfficePhone,
|
OfficePhone = x.OfficePhone,
|
||||||
EmployeeFullName = x.FName + " " + x.LName,
|
EmployeeFullName = x.FName + " " + x.LName,
|
||||||
MclsUserName =x.MclsUserName,
|
MclsUserName = x.MclsUserName,
|
||||||
MclsPassword = x.MclsPassword,
|
MclsPassword = x.MclsPassword,
|
||||||
EserviceUserName = x.EserviceUserName,
|
EserviceUserName = x.EserviceUserName,
|
||||||
EservicePassword = x.EservicePassword,
|
EservicePassword = x.EservicePassword,
|
||||||
TaxOfficeUserName = x.TaxOfficeUserName,
|
TaxOfficeUserName = x.TaxOfficeUserName,
|
||||||
TaxOfficepassword = x.TaxOfficepassword,
|
TaxOfficepassword = x.TaxOfficepassword,
|
||||||
SanaUserName = x.SanaUserName,
|
SanaUserName = x.SanaUserName,
|
||||||
SanaPassword = x.SanaPassword,
|
SanaPassword = x.SanaPassword,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
.FirstOrDefault(x => x.Id == id);
|
.FirstOrDefault(x => x.Id == id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<EmployeeViewModel>> Search(EmployeeSearchModel searchModel)
|
public async Task<List<EmployeeViewModel>> Search(EmployeeSearchModel searchModel)
|
||||||
@@ -182,10 +183,10 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
|||||||
return query.OrderByDescending(x => x.Id).Take(100).ToList();
|
return query.OrderByDescending(x => x.Id).Take(100).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<EmployeeSelectListViewModel>> GetEmployeeToList()
|
public async Task<List<EmployeeSelectListViewModel>> GetEmployeeToList()
|
||||||
{
|
{
|
||||||
var watch = System.Diagnostics.Stopwatch.StartNew();
|
var watch = System.Diagnostics.Stopwatch.StartNew();
|
||||||
|
|
||||||
List<EmployeeSelectListViewModel> result = null;
|
List<EmployeeSelectListViewModel> result = null;
|
||||||
var connection = _configuration.GetConnectionString("MesbahDb");
|
var connection = _configuration.GetConnectionString("MesbahDb");
|
||||||
using (var conn = new SqlConnection(connection))
|
using (var conn = new SqlConnection(connection))
|
||||||
@@ -195,7 +196,7 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
|||||||
var command = new SqlCommand("EmployeeFullNameId", conn);
|
var command = new SqlCommand("EmployeeFullNameId", conn);
|
||||||
command.CommandType = CommandType.StoredProcedure;
|
command.CommandType = CommandType.StoredProcedure;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using (var reader = await command.ExecuteReaderAsync())
|
using (var reader = await command.ExecuteReaderAsync())
|
||||||
{
|
{
|
||||||
@@ -273,45 +274,45 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
|||||||
public EditEmployee GetDetailsByADDate(long id)
|
public EditEmployee GetDetailsByADDate(long id)
|
||||||
{
|
{
|
||||||
return _context.Employees.Select(x => new EditEmployee
|
return _context.Employees.Select(x => new EditEmployee
|
||||||
{
|
{
|
||||||
Id = x.id,
|
Id = x.id,
|
||||||
FName = x.FName,
|
FName = x.FName,
|
||||||
LName = x.LName,
|
LName = x.LName,
|
||||||
Gender = x.Gender,
|
Gender = x.Gender,
|
||||||
NationalCode = x.NationalCode,
|
NationalCode = x.NationalCode,
|
||||||
IdNumber = x.IdNumber,
|
IdNumber = x.IdNumber,
|
||||||
Nationality = x.Nationality,
|
Nationality = x.Nationality,
|
||||||
FatherName = x.FatherName,
|
FatherName = x.FatherName,
|
||||||
DateOfBirthGr = x.DateOfBirth ,
|
DateOfBirthGr = x.DateOfBirth,
|
||||||
DateOfIssueGr = x.DateOfIssue ,
|
DateOfIssueGr = x.DateOfIssue,
|
||||||
DateOfBirth = x.DateOfBirth.ToFarsi(),
|
DateOfBirth = x.DateOfBirth.ToFarsi(),
|
||||||
DateOfIssue = x.DateOfIssue.ToFarsi(),
|
DateOfIssue = x.DateOfIssue.ToFarsi(),
|
||||||
PlaceOfIssue = x.PlaceOfIssue,
|
PlaceOfIssue = x.PlaceOfIssue,
|
||||||
Phone = x.Phone,
|
Phone = x.Phone,
|
||||||
Address = x.Address,
|
Address = x.Address,
|
||||||
State = x.State,
|
State = x.State,
|
||||||
City = x.City,
|
City = x.City,
|
||||||
MaritalStatus = x.MaritalStatus,
|
MaritalStatus = x.MaritalStatus,
|
||||||
MilitaryService = x.MilitaryService,
|
MilitaryService = x.MilitaryService,
|
||||||
LevelOfEducation = x.LevelOfEducation,
|
LevelOfEducation = x.LevelOfEducation,
|
||||||
FieldOfStudy = x.FieldOfStudy,
|
FieldOfStudy = x.FieldOfStudy,
|
||||||
BankCardNumber = x.BankCardNumber,
|
BankCardNumber = x.BankCardNumber,
|
||||||
BankBranch = x.BankBranch,
|
BankBranch = x.BankBranch,
|
||||||
InsuranceCode = x.InsuranceCode,
|
InsuranceCode = x.InsuranceCode,
|
||||||
InsuranceHistoryByYear = x.InsuranceHistoryByYear,
|
InsuranceHistoryByYear = x.InsuranceHistoryByYear,
|
||||||
InsuranceHistoryByMonth = x.InsuranceHistoryByMonth,
|
InsuranceHistoryByMonth = x.InsuranceHistoryByMonth,
|
||||||
NumberOfChildren = x.NumberOfChildren,
|
NumberOfChildren = x.NumberOfChildren,
|
||||||
OfficePhone = x.OfficePhone,
|
OfficePhone = x.OfficePhone,
|
||||||
EmployeeFullName = x.FName + " " + x.LName,
|
EmployeeFullName = x.FName + " " + x.LName,
|
||||||
MclsUserName = x.MclsUserName,
|
MclsUserName = x.MclsUserName,
|
||||||
MclsPassword = x.MclsPassword,
|
MclsPassword = x.MclsPassword,
|
||||||
EserviceUserName = x.EserviceUserName,
|
EserviceUserName = x.EserviceUserName,
|
||||||
EservicePassword = x.EservicePassword,
|
EservicePassword = x.EservicePassword,
|
||||||
TaxOfficeUserName = x.TaxOfficeUserName,
|
TaxOfficeUserName = x.TaxOfficeUserName,
|
||||||
TaxOfficepassword = x.TaxOfficepassword,
|
TaxOfficepassword = x.TaxOfficepassword,
|
||||||
SanaUserName = x.SanaUserName,
|
SanaUserName = x.SanaUserName,
|
||||||
SanaPassword = x.SanaPassword,
|
SanaPassword = x.SanaPassword,
|
||||||
})
|
})
|
||||||
.FirstOrDefault(x => x.Id == id);
|
.FirstOrDefault(x => x.Id == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,7 +325,7 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
|||||||
EmployeeFullName = x.FName + " " + x.LName,
|
EmployeeFullName = x.FName + " " + x.LName,
|
||||||
IsActive = x.IsActive
|
IsActive = x.IsActive
|
||||||
|
|
||||||
}).Where(x=>x.IsActive).ToList();
|
}).Where(x => x.IsActive).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Client
|
#region Client
|
||||||
@@ -452,7 +453,7 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
|||||||
|
|
||||||
var employeeData = new Employee(command.FName, command.LName, command.FatherName, dateOfBirth,
|
var employeeData = new Employee(command.FName, command.LName, command.FatherName, dateOfBirth,
|
||||||
dateOfIssue,
|
dateOfIssue,
|
||||||
command.PlaceOfIssue, command.NationalCode, command.IdNumber, command.Gender, command.Nationality,command.IdNumberSerial,command.IdNumberSeri,
|
command.PlaceOfIssue, command.NationalCode, command.IdNumber, command.Gender, command.Nationality, command.IdNumberSerial, command.IdNumberSeri,
|
||||||
command.Phone, command.Address,
|
command.Phone, command.Address,
|
||||||
command.State, command.City, command.MaritalStatus, command.MilitaryService, command.LevelOfEducation,
|
command.State, command.City, command.MaritalStatus, command.MilitaryService, command.LevelOfEducation,
|
||||||
command.FieldOfStudy, command.BankCardNumber,
|
command.FieldOfStudy, command.BankCardNumber,
|
||||||
@@ -706,20 +707,20 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
|||||||
{
|
{
|
||||||
case null:
|
case null:
|
||||||
case "":
|
case "":
|
||||||
query = query.Where(x => x.IsActive == true).ToList();
|
query = query.Where(x => x.IsActive == true).ToList();
|
||||||
break;
|
break;
|
||||||
case "false":
|
case "false":
|
||||||
query = query.Where(x => x.IsActive == false).ToList();
|
query = query.Where(x => x.IsActive == false).ToList();
|
||||||
hasSearch = true;
|
hasSearch = true;
|
||||||
break;
|
break;
|
||||||
case "both":
|
case "both":
|
||||||
query = query.Where(x => x.IsActive == true || x.IsActive == false).ToList();
|
query = query.Where(x => x.IsActive == true || x.IsActive == false).ToList();
|
||||||
hasSearch = true;
|
hasSearch = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (hasSearch)
|
if (hasSearch)
|
||||||
{
|
{
|
||||||
return query.OrderByDescending(x => x.Id).ToList();
|
return query.OrderByDescending(x => x.Id).ToList();
|
||||||
@@ -816,11 +817,11 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
|||||||
var employeesQuery = _context.Employees.Where(x =>
|
var employeesQuery = _context.Employees.Where(x =>
|
||||||
workshopActiveLeftWorksQuery.Any(y => y.EmployeeId == x.id) ||
|
workshopActiveLeftWorksQuery.Any(y => y.EmployeeId == x.id) ||
|
||||||
workshopActiveInsuranceLeftWorksQuery.Any(y => y.EmployeeId == x.id)).Select(x => new
|
workshopActiveInsuranceLeftWorksQuery.Any(y => y.EmployeeId == x.id)).Select(x => new
|
||||||
{
|
{
|
||||||
leftWork = workshopActiveLeftWorksQuery.Where(l => l.EmployeeId == x.id).OrderByDescending(i => i.StartWorkDate).FirstOrDefault(),
|
leftWork = workshopActiveLeftWorksQuery.Where(l => l.EmployeeId == x.id).OrderByDescending(i => i.StartWorkDate).FirstOrDefault(),
|
||||||
insuranceLeftWork = workshopActiveInsuranceLeftWorksQuery.Where(i => i.EmployeeId == x.id).OrderByDescending(i => i.StartWorkDate).FirstOrDefault(),
|
insuranceLeftWork = workshopActiveInsuranceLeftWorksQuery.Where(i => i.EmployeeId == x.id).OrderByDescending(i => i.StartWorkDate).FirstOrDefault(),
|
||||||
Employee = x
|
Employee = x
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -878,7 +879,7 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
|||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<GetEditEmployeeInEmployeeDocumentViewModel> GetEmployeeEditInEmployeeDocumentWorkFlow(long employeeId, long workshopId)
|
public async Task<GetEditEmployeeInEmployeeDocumentViewModel> GetEmployeeEditInEmployeeDocumentWorkFlow(long employeeId, long workshopId)
|
||||||
{
|
{
|
||||||
var employee = await _context.Employees.Where(x => x.id == employeeId).Select(x => new GetEditEmployeeInEmployeeDocumentViewModel()
|
var employee = await _context.Employees.Where(x => x.id == employeeId).Select(x => new GetEditEmployeeInEmployeeDocumentViewModel()
|
||||||
@@ -946,13 +947,13 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
|||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Api
|
#region Api
|
||||||
|
|
||||||
public async Task<List<EmployeeSelectListViewModel>> GetSelectList(string searchText,long id)
|
public async Task<List<EmployeeSelectListViewModel>> GetSelectList(string searchText, long id)
|
||||||
{
|
{
|
||||||
var query = _context.Employees.AsQueryable();
|
var query = _context.Employees.AsQueryable();
|
||||||
EmployeeSelectListViewModel idSelected = null;
|
EmployeeSelectListViewModel idSelected = null;
|
||||||
if (id > 0)
|
if (id > 0)
|
||||||
{
|
{
|
||||||
@@ -963,104 +964,104 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
|||||||
}).FirstOrDefaultAsync(x => x.Id == id);
|
}).FirstOrDefaultAsync(x => x.Id == id);
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrWhiteSpace(searchText))
|
if (!string.IsNullOrWhiteSpace(searchText))
|
||||||
{
|
{
|
||||||
query = query.Where(x => (x.FName + " " + x.LName).Contains(searchText));
|
query = query.Where(x => (x.FName + " " + x.LName).Contains(searchText));
|
||||||
}
|
}
|
||||||
|
|
||||||
var list = await query.Take(100).Select(x => new EmployeeSelectListViewModel()
|
var list = await query.Take(100).Select(x => new EmployeeSelectListViewModel()
|
||||||
{
|
{
|
||||||
Id = x.id,
|
Id = x.id,
|
||||||
EmployeeFullName = x.FName + " " + x.LName
|
EmployeeFullName = x.FName + " " + x.LName
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
|
|
||||||
if (idSelected != null)
|
if (idSelected != null)
|
||||||
list.Add(idSelected);
|
list.Add(idSelected);
|
||||||
|
|
||||||
return list.DistinctBy(x=>x.Id).ToList();
|
return list.DistinctBy(x => x.Id).ToList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel)
|
public async Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel)
|
||||||
{
|
{
|
||||||
var query = _context.Employees.Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances).AsQueryable();
|
var query = _context.Employees.Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances).AsQueryable();
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(searchModel.NationalCode))
|
if (!string.IsNullOrWhiteSpace(searchModel.NationalCode))
|
||||||
{
|
{
|
||||||
query = query.Where(x => x.NationalCode.Contains(searchModel.NationalCode));
|
query = query.Where(x => x.NationalCode.Contains(searchModel.NationalCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchModel.EmployeeId > 0)
|
if (searchModel.EmployeeId > 0)
|
||||||
{
|
{
|
||||||
query = query.Where(x => x.id == searchModel.EmployeeId);
|
query = query.Where(x => x.id == searchModel.EmployeeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchModel.WorkshopId > 0)
|
if (searchModel.WorkshopId > 0)
|
||||||
{
|
{
|
||||||
query = query.Where(x => x.LeftWorks.Any(l => l.WorkshopId == searchModel.WorkshopId) || x.LeftWorkInsurances.Any(l => l.WorkshopId == searchModel.WorkshopId));
|
query = query.Where(x => x.LeftWorks.Any(l => l.WorkshopId == searchModel.WorkshopId) || x.LeftWorkInsurances.Any(l => l.WorkshopId == searchModel.WorkshopId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#region employer
|
#region employer
|
||||||
|
|
||||||
if (searchModel.EmployerId > 0)
|
if (searchModel.EmployerId > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
var workshopIdsByEmployer = _context.WorkshopEmployers.Where(x => x.EmployerId == searchModel.EmployerId)
|
var workshopIdsByEmployer = _context.WorkshopEmployers.Where(x => x.EmployerId == searchModel.EmployerId)
|
||||||
.Include(x => x.Workshop).Select(x => x.Workshop.id).AsQueryable();
|
.Include(x => x.Workshop).Select(x => x.Workshop.id).AsQueryable();
|
||||||
|
|
||||||
query = query.Where(x =>
|
query = query.Where(x =>
|
||||||
x.LeftWorks.Any(l => workshopIdsByEmployer.Contains(l.WorkshopId)) ||
|
x.LeftWorks.Any(l => workshopIdsByEmployer.Contains(l.WorkshopId)) ||
|
||||||
x.LeftWorkInsurances.Any(l => workshopIdsByEmployer.Contains(l.WorkshopId)));
|
x.LeftWorkInsurances.Any(l => workshopIdsByEmployer.Contains(l.WorkshopId)));
|
||||||
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(searchModel.InsuranceCode))
|
if (!string.IsNullOrEmpty(searchModel.InsuranceCode))
|
||||||
{
|
{
|
||||||
query = query.Where(x => x.InsuranceCode.Contains(searchModel.InsuranceCode));
|
query = query.Where(x => x.InsuranceCode.Contains(searchModel.InsuranceCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchModel.EmployeeStatus != ActivationStatus.None)
|
if (searchModel.EmployeeStatus != ActivationStatus.None)
|
||||||
{
|
{
|
||||||
var status = searchModel.EmployeeStatus switch
|
var status = searchModel.EmployeeStatus switch
|
||||||
{
|
{
|
||||||
ActivationStatus.Active => true,
|
ActivationStatus.Active => true,
|
||||||
ActivationStatus.DeActive => false,
|
ActivationStatus.DeActive => false,
|
||||||
_ => throw new BadRequestException("پارامتر جستجو نامعتبر است")
|
_ => throw new BadRequestException("پارامتر جستجو نامعتبر است")
|
||||||
};
|
};
|
||||||
query = query.Where(x => x.IsActiveString == status.ToString() || x.IsActive == status);
|
query = query.Where(x => x.IsActiveString == status.ToString() || x.IsActive == status);
|
||||||
}
|
}
|
||||||
|
|
||||||
var list = await query.Skip(searchModel.PageIndex).Take(30).ToListAsync();
|
var list = await query.Skip(searchModel.PageIndex).Take(30).ToListAsync();
|
||||||
|
|
||||||
var employeeIds = list.Select(x => x.id);
|
var employeeIds = list.Select(x => x.id);
|
||||||
|
|
||||||
var children = await _context.EmployeeChildrenSet.Where(x => employeeIds.Contains(x.EmployeeId)).ToListAsync();
|
var children = await _context.EmployeeChildrenSet.Where(x => employeeIds.Contains(x.EmployeeId)).ToListAsync();
|
||||||
|
|
||||||
var result = list.Select(x => new GetEmployeeListViewModel()
|
var result = list.Select(x => new GetEmployeeListViewModel()
|
||||||
{
|
{
|
||||||
BirthDate = x.DateOfBirth.ToFarsi(),
|
BirthDate = x.DateOfBirth.ToFarsi(),
|
||||||
ChildrenCount = children.Count(c => c.EmployeeId == x.id).ToString(),
|
ChildrenCount = children.Count(c => c.EmployeeId == x.id).ToString(),
|
||||||
EmployeeFullName = x.FullName,
|
EmployeeFullName = x.FullName,
|
||||||
EmployeeStatus = x.IsActive switch
|
EmployeeStatus = x.IsActive switch
|
||||||
{
|
{
|
||||||
true => ActivationStatus.Active,
|
true => ActivationStatus.Active,
|
||||||
false => ActivationStatus.DeActive
|
false => ActivationStatus.DeActive
|
||||||
},
|
},
|
||||||
Gender = x.Gender switch
|
Gender = x.Gender switch
|
||||||
{
|
{
|
||||||
"مرد" => Gender.Male,
|
"مرد" => Gender.Male,
|
||||||
"زن" => Gender.Female,
|
"زن" => Gender.Female,
|
||||||
_ => Gender.None
|
_ => Gender.None
|
||||||
},
|
},
|
||||||
Id = x.id,
|
Id = x.id,
|
||||||
InsuranceCode = x.InsuranceCode,
|
InsuranceCode = x.InsuranceCode,
|
||||||
NationalCode = x.NationalCode
|
NationalCode = x.NationalCode
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<List<GetClientEmployeeListViewModel>> GetClientEmployeeList(GetClientEmployeeListSearchModel searchModel, long workshopId)
|
public Task<List<GetClientEmployeeListViewModel>> GetClientEmployeeList(GetClientEmployeeListSearchModel searchModel, long workshopId)
|
||||||
{
|
{
|
||||||
@@ -1170,7 +1171,144 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
|||||||
//
|
//
|
||||||
// };
|
// };
|
||||||
// }).OrderByDescending(x => x.StartWork).ToList();
|
// }).OrderByDescending(x => x.StartWork).ToList();
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<List<EmployeeListDto>> ListOfAllEmployeesClient(EmployeeSearchModelDto searchModel, long workshopId)
|
||||||
|
{
|
||||||
|
var hasNotStoppedWorkingYet = Tools.GetUndefinedDateTime();
|
||||||
|
|
||||||
|
var baseQuery = await
|
||||||
|
(
|
||||||
|
from personnelCode in _context.PersonnelCodeSet
|
||||||
|
join employee in _context.Employees
|
||||||
|
on personnelCode.EmployeeId equals employee.id
|
||||||
|
where personnelCode.WorkshopId == workshopId
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
Employee = employee,
|
||||||
|
PersonnelCode = personnelCode
|
||||||
|
}
|
||||||
|
).ToListAsync();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(searchModel.EmployeeFullName))
|
||||||
|
baseQuery = baseQuery.Where(x => x.Employee.FullName.Contains(searchModel.EmployeeFullName)).ToList();
|
||||||
|
if (!string.IsNullOrWhiteSpace(searchModel.NationalCode))
|
||||||
|
baseQuery = baseQuery.Where(x => x.Employee.NationalCode.Contains(searchModel.NationalCode)).ToList();
|
||||||
|
|
||||||
|
var employeeIds = baseQuery.Select(x => x.Employee.id).ToList();
|
||||||
|
|
||||||
|
var leftWorks = await _context.LeftWorkList
|
||||||
|
.Where(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId))
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
var insuranceLeftWorks = await _context.LeftWorkInsuranceList
|
||||||
|
.Where(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId))
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
var children = await _context.EmployeeChildrenSet.Where(x => employeeIds.Contains(x.EmployeeId)).ToListAsync();
|
||||||
|
|
||||||
|
var clientTemp = await _context.EmployeeClientTemps.Where(x => x.WorkshopId == workshopId)
|
||||||
|
.Select(x => x.EmployeeId).ToListAsync();
|
||||||
|
var leftWorkTempData = await _context.LeftWorkTemps.Where(x => x.WorkshopId == workshopId).ToListAsync();
|
||||||
|
var startWorkTemp = leftWorkTempData.Where(x => x.LeftWorkType == LeftWorkTempType.StartWork).ToList();
|
||||||
|
var leftWorkTemp = leftWorkTempData.Where(x => x.LeftWorkType == LeftWorkTempType.LeftWork).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var result = baseQuery.Select(x =>
|
||||||
|
{
|
||||||
|
var left = leftWorks
|
||||||
|
.Where(l => l.EmployeeId == x.Employee.id)
|
||||||
|
.MaxBy(l => l.StartWorkDate);
|
||||||
|
|
||||||
|
var insuranceLeftWork = insuranceLeftWorks
|
||||||
|
.Where(l => l.EmployeeId == x.Employee.id).MaxBy(l => l.StartWorkDate);
|
||||||
|
|
||||||
|
var contractStart = left != null ? left.StartWorkDate.ToFarsi() : "";
|
||||||
|
var contractLeft = left != null
|
||||||
|
? left.LeftWorkDate != hasNotStoppedWorkingYet ? left.LeftWorkDate.ToFarsi() : ""
|
||||||
|
: "";
|
||||||
|
|
||||||
|
var insuranceStart = insuranceLeftWork != null ? insuranceLeftWork.StartWorkDate.ToFarsi() : "";
|
||||||
|
var insuranceLeft = insuranceLeftWork != null
|
||||||
|
? insuranceLeftWork.LeftWorkDate != null ? insuranceLeftWork.LeftWorkDate.ToFarsi() : ""
|
||||||
|
: "";
|
||||||
|
int personnelCode = Convert.ToInt32($"{x.PersonnelCode.PersonnelCode}");
|
||||||
|
|
||||||
|
int numberOfChildren = children.Count(ch => ch.EmployeeId == x.Employee.id);
|
||||||
|
|
||||||
|
bool employeeHasLeft =
|
||||||
|
(!string.IsNullOrWhiteSpace(insuranceLeft) && !string.IsNullOrWhiteSpace(contractLeft))
|
||||||
|
|| (left == null && !string.IsNullOrWhiteSpace(insuranceLeft))
|
||||||
|
|| (insuranceLeftWork == null && !string.IsNullOrWhiteSpace(contractLeft));
|
||||||
|
bool hasClientTemp = clientTemp.Any(c => c == x.Employee.id);
|
||||||
|
bool hasStartWorkTemp = startWorkTemp.Any(st => st.EmployeeId == x.Employee.id);
|
||||||
|
bool hasLeftWorkTemp = leftWorkTemp.Any(lf => lf.EmployeeId == x.Employee.id);
|
||||||
|
return new EmployeeListDto
|
||||||
|
{
|
||||||
|
Id = x.Employee.id,
|
||||||
|
EmployeeFullName = x.Employee.FullName,
|
||||||
|
PersonnelCode = personnelCode,
|
||||||
|
MaritalStatus = x.Employee.MaritalStatus,
|
||||||
|
NationalCode = x.Employee.NationalCode,
|
||||||
|
IdNumber = x.Employee.IdNumber,
|
||||||
|
DateOfBirth = x.Employee.DateOfBirth.ToFarsi(),
|
||||||
|
FatherName = x.Employee.FatherName,
|
||||||
|
NumberOfChildren = $"{numberOfChildren}",
|
||||||
|
LatestContractStartDate = contractStart,
|
||||||
|
ContractLeftDate = contractLeft,
|
||||||
|
LatestInsuranceStartDate = insuranceStart,
|
||||||
|
InsuranceLeftDate = insuranceLeft,
|
||||||
|
HasContract = !string.IsNullOrWhiteSpace(contractStart),
|
||||||
|
HasInsurance = !string.IsNullOrWhiteSpace(insuranceStart),
|
||||||
|
EmployeeStatusInWorkshop =
|
||||||
|
hasClientTemp || hasStartWorkTemp ? EmployeeStatusInWorkshop.CreatedByClient :
|
||||||
|
hasLeftWorkTemp ? EmployeeStatusInWorkshop.LefWorkTemp :
|
||||||
|
employeeHasLeft ? EmployeeStatusInWorkshop.HasLeft : EmployeeStatusInWorkshop.Working,
|
||||||
|
|
||||||
|
};
|
||||||
|
}).OrderBy(x => x.EmployeeStatusInWorkshop).ThenBy(x => x.PersonnelCode).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<List<PrintAllEmployeesInfoDtoClient>> PrintAllEmployeesInfoClient(long workshopId)
|
||||||
|
{
|
||||||
|
var res = await ListOfAllEmployeesClient(new EmployeeSearchModelDto(), workshopId);
|
||||||
|
|
||||||
|
return res
|
||||||
|
.Where(x=>x.EmployeeStatusInWorkshop != EmployeeStatusInWorkshop.CreatedByClient
|
||||||
|
&& x.EmployeeStatusInWorkshop != EmployeeStatusInWorkshop.LefWorkTemp)
|
||||||
|
.Select(x => new PrintAllEmployeesInfoDtoClient(x)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<EmployeeSelectListViewModel>> GetWorkingEmployeesSelectList(long workshopId)
|
||||||
|
{
|
||||||
|
var dateNow = DateTime.Now.Date;
|
||||||
|
|
||||||
|
|
||||||
|
var workshopActiveLeftWorksQuery = _context.LeftWorkList.Where(x => x.WorkshopId == workshopId &&
|
||||||
|
x.StartWorkDate <= dateNow && x.LeftWorkDate > dateNow);
|
||||||
|
|
||||||
|
|
||||||
|
var workshopActiveInsuranceLeftWorksQuery = _context.LeftWorkInsuranceList.Where(x => x.WorkshopId == workshopId &&
|
||||||
|
x.StartWorkDate <= dateNow && (x.LeftWorkDate > dateNow || x.LeftWorkDate == null));
|
||||||
|
|
||||||
|
|
||||||
|
var employeesQuery = _context.Employees.Where(x => workshopActiveLeftWorksQuery.Any(y => y.EmployeeId == x.id) ||
|
||||||
|
workshopActiveInsuranceLeftWorksQuery.Any(y => y.EmployeeId == x.id));
|
||||||
|
|
||||||
|
|
||||||
|
return await employeesQuery.Select(x => new EmployeeSelectListViewModel()
|
||||||
|
{
|
||||||
|
Id = x.id,
|
||||||
|
EmployeeFullName = x.FullName
|
||||||
|
}).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using _0_Framework.Application;
|
using _0_Framework.Application;
|
||||||
using CompanyManagment.App.Contracts.Employee;
|
using CompanyManagment.App.Contracts.Employee;
|
||||||
|
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using ServiceHost.BaseControllers;
|
using ServiceHost.BaseControllers;
|
||||||
|
|
||||||
@@ -16,10 +17,38 @@ public class EmployeeController:ClientBaseController
|
|||||||
_workshopId = authHelper.GetWorkshopId();
|
_workshopId = authHelper.GetWorkshopId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpGet("select-list")]
|
[HttpGet("select-list")]
|
||||||
public async Task<ActionResult<List<EmployeeSelectListViewModel>>> GetEmployeeSelectList()
|
public async Task<ActionResult<List<EmployeeSelectListViewModel>>> GetEmployeeSelectList()
|
||||||
{
|
{
|
||||||
var result = await _employeeApplication.WorkedEmployeesInWorkshopSelectList(_workshopId);
|
var result = await _employeeApplication.GetWorkingEmployeesSelectList(_workshopId);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// دریافت لیست پرسنل
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="searchModel"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<List<EmployeeListDto>>> GetList(EmployeeSearchModelDto searchModel)
|
||||||
|
{
|
||||||
|
var result = await _employeeApplication.ListOfAllEmployeesClient(searchModel, _workshopId);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// پرینت تجمیعی پرسنل
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("PrintAllEmployeesInfo")]
|
||||||
|
public async Task<ActionResult<List<PrintAllEmployeesInfoDtoClient>>> PrintAllEmployeesInfo()
|
||||||
|
{
|
||||||
|
var result = await _employeeApplication.PrintAllEmployeesInfoClient(_workshopId);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user