add employee client api
This commit is contained in:
@@ -76,6 +76,7 @@ public interface IEmployeeRepository : IRepository<long, Employee>
|
||||
#region Api
|
||||
Task<List<EmployeeSelectListViewModel>> GetSelectList(string searchText,long id);
|
||||
Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel);
|
||||
Task<List<GetClientEmployeeListViewModel>> GetClientEmployeeList(GetClientEmployeeListSearchModel searchModel, long workshopId);
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@@ -95,6 +95,41 @@ public interface IEmployeeApplication
|
||||
/// <returns></returns>
|
||||
Task<List<GetEmployeeListViewModel>> GetList(GetEmployeeListSearchModel searchModel);
|
||||
|
||||
/// <summary>
|
||||
/// لیست کل پرسنل کلاینت
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<GetClientEmployeeListViewModel>> GetClientEmployeeList(GetClientEmployeeListSearchModel searchModel, long workshopId);
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
public class GetClientEmployeeListSearchModel
|
||||
{
|
||||
}
|
||||
|
||||
public class GetClientEmployeeListViewModel
|
||||
{
|
||||
public string FullName { get; set; }
|
||||
public long EmployeeId { get; set; }
|
||||
public long WorkshopId { get; set; }
|
||||
public long PersonnelCode { get; set; }
|
||||
public string MaritalStatus { get; set; }
|
||||
public string NationalCode { get; set; }
|
||||
public string IdNumber { get; set; }
|
||||
public string DateOfBirthFa { get; set; }
|
||||
public string FatherName { get; set; }
|
||||
public int ChildrenCount { get; set; }
|
||||
public string LastStartInsuranceWork { get; set; }
|
||||
public string LastLeftInsuranceWork { get; set; }
|
||||
public string LastStartContractWork { get; set; }
|
||||
public string LastLeftContractWork { get; set; }
|
||||
public bool HasContractLeftWork { get; set; }
|
||||
public bool HasInsuranceLeftWork { get; set; }
|
||||
public bool LeftWorkCompletely { get; set; }
|
||||
public bool PendingStartWork { get; set; }
|
||||
public bool PendingLeftWork { get; set; }
|
||||
}
|
||||
@@ -1729,5 +1729,10 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
return await _EmployeeRepository.GetList(searchModel);
|
||||
}
|
||||
|
||||
public async Task<List<GetClientEmployeeListViewModel>> GetClientEmployeeList(GetClientEmployeeListSearchModel searchModel, long workshopId)
|
||||
{
|
||||
return await _EmployeeRepository.GetClientEmployeeList(searchModel, workshopId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1062,5 +1062,116 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
|
||||
}
|
||||
|
||||
public Task<List<GetClientEmployeeListViewModel>> GetClientEmployeeList(GetClientEmployeeListSearchModel searchModel, long workshopId)
|
||||
{
|
||||
// var leftDate = Tools.GetUndefinedDateTime();
|
||||
//
|
||||
// var personnelCodes = _context.PersonnelCodeSet.Include(x => x.Employee)
|
||||
// .ThenInclude(x => x.EmployeeChildrenList).IgnoreQueryFilters().Where(x => x.WorkshopId == workshopId).ToList();
|
||||
//
|
||||
// var contractLeftWork =
|
||||
// _context.LeftWorkList.Where(x => x.WorkshopId == workshopId)
|
||||
// .GroupBy(x => x.EmployeeId).Select(x => x.OrderByDescending(y => y.LeftWork).First()).ToList();
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// var insuranceLeftWork = _context.LeftWorkInsuranceList.Where(x => x.WorkshopId == workshopId).Select(x => new
|
||||
// {
|
||||
// EmployeeId = x.EmployeeId,
|
||||
// FullName = x.EmployeeFullName,
|
||||
// PersonnelCode = 0,
|
||||
// InsurancePerson = true,
|
||||
// InsuranceLeft = x.LeftWorkDate != null,
|
||||
// StartWork = x.StartWorkDate,
|
||||
// LeftWork = x.LeftWorkDate ?? leftDate,
|
||||
// LastStartInsuranceWork = x.StartWorkDate.ToFarsi(),
|
||||
// LastLeftInsuranceWork = x.LeftWorkDate != null ? x.LeftWorkDate.ToFarsi() : "-",
|
||||
// LastStartContractWork = "-",
|
||||
// LastLeftContractWork = "-"
|
||||
// }).GroupBy(x => x.EmployeeId)
|
||||
// .Select(x => x.OrderByDescending(y => y.LeftWork).First()).ToList();
|
||||
//
|
||||
// var leftWorkTemp = _context.LeftWorkTemps.Where(x => x.WorkshopId == workshopId).Select(x => new
|
||||
// {
|
||||
// WorkshopId = x.WorkshopId,
|
||||
// EmployeeId = x.EmployeeId,
|
||||
// PersonnelCode = 0,
|
||||
// ContractPerson = true,
|
||||
// ContractLeft = x.LeftWork != leftDate,
|
||||
// StartWork = x.StartWork,
|
||||
// LeftWork = x.LeftWork,
|
||||
// LastStartContractWork = x.StartWork.ToFarsi(),
|
||||
// LastLeftContractWork = x.LeftWork != leftDate ? x.LeftWork.ToFarsi() : "-",
|
||||
// LastStartInsuranceWork = "-",
|
||||
// LastLeftInsuranceWork = "-",
|
||||
// LefWorkTemp = x.LeftWorkType == LeftWorkTempType.LeftWork,
|
||||
// CreatedByClient = x.LeftWorkType == LeftWorkTempType.StartWork
|
||||
// }).ToList();
|
||||
//
|
||||
//
|
||||
// var employeeClientTemp = _context.EmployeeClientTemps.Where(x => x.WorkshopId == workshopId).Select(x => new
|
||||
// {
|
||||
// WorkshopId = x.WorkshopId,
|
||||
// EmployeeId = x.EmployeeId,
|
||||
// PersonnelCode = 0,
|
||||
// CreatedByClient = true,
|
||||
// ContractPerson = true
|
||||
// }).ToList();
|
||||
//
|
||||
// var resultTemp = employeeClientTemp.Concat(leftWorkTemp).ToList().GroupBy(x => x.EmployeeId);
|
||||
//
|
||||
//
|
||||
//
|
||||
// var result = contractLeftWork.Concat(insuranceLeftWork).GroupBy(x => x.EmployeeId).ToList();
|
||||
//
|
||||
// result = result.Concat(resultTemp).GroupBy(x => x.First().EmployeeId).Select(x => x.First()).ToList();
|
||||
//
|
||||
// var employeeClientTempList = employeeClientTemp.ToList();
|
||||
// var startWorkTempsForWorkshop = leftWorkTemp.Where(x => x.CreatedByClient).ToList();
|
||||
// var leftWorkTempsForWorkshop = leftWorkTemp.Where(x => x.LefWorkTemp).ToList();
|
||||
//
|
||||
// return result.Select(x =>
|
||||
// {
|
||||
// var insurance = x.FirstOrDefault(y => y.InsurancePerson);
|
||||
// var contract = x.FirstOrDefault(y => y.ContractPerson);
|
||||
// var personnelCode = personnelCodes.FirstOrDefault(y => y.EmployeeId == x.Key);
|
||||
// var employee = personnelCode.Employee;
|
||||
// var employeeClient = employeeClientTempList.FirstOrDefault(t => t.EmployeeId == x.First().EmployeeId);
|
||||
// var startWorkTemp = startWorkTempsForWorkshop.FirstOrDefault(s => s.EmployeeId == x.First().EmployeeId);
|
||||
// var leftWorkTemp = leftWorkTempsForWorkshop.FirstOrDefault(s => s.EmployeeId == x.First().EmployeeId);
|
||||
//
|
||||
//
|
||||
// return new GetClientEmployeeListViewModel()
|
||||
// {
|
||||
// EmployeeId = x.Key,
|
||||
// FullName = employee.FullName,
|
||||
// PersonnelCode = personnelCode?.PersonnelCode ?? 0,
|
||||
// HasContractLeftWork = insurance != null,
|
||||
// HasInsuranceLeftWork = contract != null,
|
||||
//
|
||||
// LeftWorkCompletely = (insurance?.InsuranceLeft ?? false) && (contract?.ContractLeft ?? false),
|
||||
//
|
||||
// LastStartInsuranceWork = insurance != null ? insurance.LastStartInsuranceWork : "-",
|
||||
// LastLeftInsuranceWork = insurance != null ? insurance.LastLeftInsuranceWork : "-",
|
||||
// LastStartContractWork = contract != null ? contract.LastStartContractWork : "-",
|
||||
// LastLeftContractWork = contract != null ? contract.LastLeftContractWork : "-",
|
||||
//
|
||||
// NationalCode = employee.NationalCode,
|
||||
// IdNumber = employee.IdNumber,
|
||||
// MaritalStatus = employee.MaritalStatus,
|
||||
// DateOfBirthFa = employee.DateOfBirth.ToFarsi(),
|
||||
// FatherName = employee.FatherName,
|
||||
// ChildrenCount = employee.EmployeeChildrenList.Count,
|
||||
//
|
||||
// PendingStartWork = employeeClient != null || startWorkTemp != null,
|
||||
// PendingLeftWork = leftWorkTemp != null,
|
||||
//
|
||||
//
|
||||
// };
|
||||
// }).OrderByDescending(x => x.StartWork).ToList();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user