จัดการหน้าค้นหารายชื่อพนักงาน
This commit is contained in:
24
Models/search_employee/Isearch_employeeService.cs
Normal file
24
Models/search_employee/Isearch_employeeService.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
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;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public interface Isearch_employeeService
|
||||
{
|
||||
List<search_employeeViewModel> GetListByfullname(string fullname);
|
||||
List<search_employeeViewModel> GetListBySearch(search_employeeSearchModel model);
|
||||
|
||||
search_employeeWithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
36
Models/search_employee/search_employeeInputModel.cs
Normal file
36
Models/search_employee/search_employeeInputModel.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TTSW.EF;
|
||||
using TTSW.Utils;
|
||||
using TTSW.Constant;
|
||||
using TTSW.Common;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class search_employeeInputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public Guid? eva_evaluation_group_id { get; set; }
|
||||
|
||||
public string employee_number { get; set; }
|
||||
|
||||
public string fullname { get; set; }
|
||||
|
||||
public string position_name { get; set; }
|
||||
|
||||
public string level_name { get; set; }
|
||||
|
||||
public int? org_id { get; set; }
|
||||
|
||||
public string remark { get; set; }
|
||||
|
||||
public string active_mode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
21
Models/search_employee/search_employeeReportRequestModel.cs
Normal file
21
Models/search_employee/search_employeeReportRequestModel.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TTSW.EF;
|
||||
using TTSW.Utils;
|
||||
using TTSW.Constant;
|
||||
using TTSW.Common;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class search_employeeReportRequestModel : search_employeeSearchModel
|
||||
{
|
||||
public string filetype { get; set; }
|
||||
|
||||
public string contentType { get { return MyHelper.GetContentType(filetype); } }
|
||||
}
|
||||
}
|
||||
|
||||
27
Models/search_employee/search_employeeSearchModel.cs
Normal file
27
Models/search_employee/search_employeeSearchModel.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TTSW.EF;
|
||||
using TTSW.Utils;
|
||||
using TTSW.Constant;
|
||||
using TTSW.Common;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class search_employeeSearchModel
|
||||
{
|
||||
|
||||
public int id { get; set; }
|
||||
|
||||
public Guid? eva_evaluation_group_id { get; set; }
|
||||
|
||||
public string fullname { get; set; }
|
||||
|
||||
public int? org_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
100
Models/search_employee/search_employeeService.cs
Normal file
100
Models/search_employee/search_employeeService.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
35
Models/search_employee/search_employeeViewModel.cs
Normal file
35
Models/search_employee/search_employeeViewModel.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TTSW.EF;
|
||||
using TTSW.Utils;
|
||||
using TTSW.Constant;
|
||||
using TTSW.Common;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class search_employeeViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public Guid? eva_evaluation_group_id { get; set; }
|
||||
|
||||
public string employee_number { get; set; }
|
||||
|
||||
public string fullname { get; set; }
|
||||
|
||||
public string position_name { get; set; }
|
||||
|
||||
public string level_name { get; set; }
|
||||
|
||||
public int? org_id { get; set; }
|
||||
|
||||
public string remark { get; set; }
|
||||
|
||||
public string eva_evaluation_group_id_eva_evaluation_group_code { get; set; }
|
||||
public string org_id_external_linkage_external_name { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class search_employeeWithSelectionViewModel: search_employeeViewModel
|
||||
{
|
||||
public List<eva_evaluation_groupEntity> item_eva_evaluation_group_id { get; set; }
|
||||
public List<external_linkageViewModel> item_org_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user