จัดการหน้าค้นหารายชื่อพนักงาน

This commit is contained in:
Nakorn Rientrakrunchai
2020-03-12 10:12:42 +07:00
parent ee1f970db6
commit 740b2d54b8
50 changed files with 847 additions and 52 deletions

View File

@@ -0,0 +1,100 @@
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TTSW.EF;
using TTSW.Utils;
using TTSW.Constant;
using TTSW.Common;
using TodoAPI2.Models;
using System.IO;
using System.Web;
using System.Net;
using TTSW.Configure;
using Microsoft.Extensions.Options;
using System.Data;
namespace TodoAPI2.Models
{
public class search_employeeService : Isearch_employeeService
{
private IBaseRepository2<eva_create_evaluationEntity, int> _repository;
private IMyDatabase db;
private Iexternal_linkageService ext;
private Iexternal_employeeService emp;
public search_employeeService(IBaseRepository2<eva_create_evaluationEntity, int> repository,
IMyDatabase mydb,
Iexternal_linkageService inext,
Iexternal_employeeService inemp)
{
db = mydb;
ext = inext;
_repository = repository;
emp = inemp;
}
public search_employeeWithSelectionViewModel GetBlankItem()
{
var i = new search_employeeWithSelectionViewModel();
i.item_eva_evaluation_group_id = (from x in _repository.Context.eva_evaluation_group orderby x.thegroup select x).ToList();
i.item_org_id = (from x in ext.GetDepartmentData() orderby x.external_name select x).ToList();
return i;
}
public List<search_employeeViewModel> GetListByfullname(string fullname)
{
var model = new search_employeeSearchModel();
model.fullname = fullname;
return GetListBySearch(model);
}
public List<search_employeeViewModel> GetListBySearch(search_employeeSearchModel model)
{
var allemp = emp.GetListByemployee_type(null, null).ToList();
var data = (
from m_search_employee in allemp
join fk_eva_evaluation_group1_detail in _repository.Context.eva_evaluation_group_detail on m_search_employee.id equals fk_eva_evaluation_group1_detail.employee_id
into eva_evaluation_groupResult1_detail
from fk_eva_evaluation_groupResult1_detail in eva_evaluation_groupResult1_detail.DefaultIfEmpty()
//join fk_eva_evaluation_group1 in _repository.Context.eva_evaluation_group on fk_eva_evaluation_groupResult1_detail.evaluation_group_id equals fk_eva_evaluation_group1.id
//into eva_evaluation_groupResult1
//from fk_eva_evaluation_groupResult1 in eva_evaluation_groupResult1.DefaultIfEmpty()
where 1 == 1
&& ((fk_eva_evaluation_groupResult1_detail != null && fk_eva_evaluation_groupResult1_detail.evaluation_group_id == model.eva_evaluation_group_id) || !model.eva_evaluation_group_id.HasValue)
&& (string.IsNullOrEmpty(model.fullname) || (!string.IsNullOrEmpty(m_search_employee.fullname) && (m_search_employee.fullname.Contains(model.fullname))))
&& (m_search_employee.department_id == model.org_id || !model.org_id.HasValue)
orderby m_search_employee.fullname
select new search_employeeViewModel()
{
id = m_search_employee.id,
eva_evaluation_group_id = fk_eva_evaluation_groupResult1_detail != null ? fk_eva_evaluation_groupResult1_detail.evaluation_group_id : null,
employee_number = m_search_employee.employee_no,
fullname = m_search_employee.fullname,
position_name = m_search_employee.position_name,
level_name = m_search_employee.position_level_text,
org_id = m_search_employee.department_id,
remark = m_search_employee.user_email,
eva_evaluation_group_id_eva_evaluation_group_code = null,
org_id_external_linkage_external_name = m_search_employee.department_name,
isActive = true,
Created = null,
Updated = null
}
).ToList();
return data;
}
}
}