diff --git a/ApiControllers/eva_create_evaluation_detail_firstdocControllers.cs b/ApiControllers/eva_create_evaluation_detail_firstdocControllers.cs index 0cb82e0..d46969c 100644 --- a/ApiControllers/eva_create_evaluation_detail_firstdocControllers.cs +++ b/ApiControllers/eva_create_evaluation_detail_firstdocControllers.cs @@ -109,7 +109,9 @@ namespace TodoAPI2.Controllers try { if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); - var result = _repository.GetBlankItem(); + var loginid = Convert.ToInt32(HttpContext.Request.Cookies["user_id"]); + var e = emp.GetEmployeeForLogin(Convert.ToInt32(loginid)); + var result = _repository.GetBlankItemWithEmp(e.id); return Ok(result); } diff --git a/ApiControllers/eva_create_evaluation_detail_processControllers.cs b/ApiControllers/eva_create_evaluation_detail_processControllers.cs index 40203d1..101e41f 100644 --- a/ApiControllers/eva_create_evaluation_detail_processControllers.cs +++ b/ApiControllers/eva_create_evaluation_detail_processControllers.cs @@ -108,7 +108,10 @@ namespace TodoAPI2.Controllers try { if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); - var result = _repository.GetBlankItem(); + + var loginid = Convert.ToInt32(HttpContext.Request.Cookies["user_id"]); + var e = emp.GetEmployeeForLogin(Convert.ToInt32(loginid)); + var result = _repository.GetBlankItemWithEmp(e.id); return Ok(result); } diff --git a/Models/eva_create_evaluation_detail_firstdoc/Ieva_create_evaluation_detail_firstdocService.cs b/Models/eva_create_evaluation_detail_firstdoc/Ieva_create_evaluation_detail_firstdocService.cs index cd7750c..93a6732 100644 --- a/Models/eva_create_evaluation_detail_firstdoc/Ieva_create_evaluation_detail_firstdocService.cs +++ b/Models/eva_create_evaluation_detail_firstdoc/Ieva_create_evaluation_detail_firstdocService.cs @@ -17,6 +17,7 @@ namespace TodoAPI2.Models eva_create_evaluation_detail_firstdocWithSelectionViewModel GetWithSelection(int id, int? emp_id); eva_create_evaluation_detail_firstdocWithSelectionViewModel GetBlankItem(); + eva_create_evaluation_detail_firstdocWithSelectionViewModel GetBlankItemWithEmp(int? emp_id); } } diff --git a/Models/eva_create_evaluation_detail_firstdoc/eva_create_evaluation_detail_firstdocService.cs b/Models/eva_create_evaluation_detail_firstdoc/eva_create_evaluation_detail_firstdocService.cs index f1609ff..50c10e8 100644 --- a/Models/eva_create_evaluation_detail_firstdoc/eva_create_evaluation_detail_firstdocService.cs +++ b/Models/eva_create_evaluation_detail_firstdoc/eva_create_evaluation_detail_firstdocService.cs @@ -222,9 +222,28 @@ namespace TodoAPI2.Models { var entity = Get(id, emp_id); var i = Mapper.Map(entity); - i.item_org_id = ext.GetDepartmentData(); + + var dep = (from x in emp.GetAllEmployee() + where x.id == emp_id + select x.department_id).FirstOrDefault(); + var alldep = (from x in emp.GetDeptMapping() + where x.id == dep || x.id2 == dep + select x.id); + var alleva = (from x in _repository.Context.eva_create_evaluation + join y in _repository.Context.eva_create_evaluation_detail on x.id equals y.create_evaluation_id + where x.employee_id == emp_id + || x.supervisor1_id == emp_id + || x.supervisor2_id == emp_id + || y.chief == emp_id + || y.eva_employee_id == emp_id + || y.supervisor1_id == emp_id + || y.supervisor2_id == emp_id + select y.employee_id).ToList(); + + i.item_org_id = (from q in ext.GetDepartmentData() where alldep.Contains(q.id) select q).ToList(); i.item_employee_id = (from x in emp.GetAllEmployee() where x.count_resigns == 0 && x.workingstatus != "คณะกรรมการเนติบัณฑิตยสภา" + && alleva.Contains(x.id) orderby x.fullname select new external_linkageViewModel { external_id = x.id, external_name = x.fullname } ).ToList(); @@ -234,6 +253,42 @@ namespace TodoAPI2.Models ).ToList(); return i; } + + public eva_create_evaluation_detail_firstdocWithSelectionViewModel GetBlankItemWithEmp(int? emp_id) + { + var i = new eva_create_evaluation_detail_firstdocWithSelectionViewModel(); + + var dep = (from x in emp.GetAllEmployee() + where x.id == emp_id + select x.department_id).FirstOrDefault(); + var alldep = (from x in emp.GetDeptMapping() + where x.id == dep || x.id2 == dep + select x.id); + var alleva = (from x in _repository.Context.eva_create_evaluation + join y in _repository.Context.eva_create_evaluation_detail on x.id equals y.create_evaluation_id + where x.employee_id == emp_id + || x.supervisor1_id == emp_id + || x.supervisor2_id == emp_id + || y.chief == emp_id + || y.eva_employee_id == emp_id + || y.supervisor1_id == emp_id + || y.supervisor2_id == emp_id + select y.employee_id).ToList(); + + i.item_org_id = (from q in ext.GetDepartmentData() where alldep.Contains(q.id) select q).ToList(); + i.item_employee_id = (from x in emp.GetAllEmployee() + where x.count_resigns == 0 && x.workingstatus != "คณะกรรมการเนติบัณฑิตยสภา" + && alleva.Contains(x.id) + orderby x.fullname + select new external_linkageViewModel { external_id = x.id, external_name = x.fullname } + ).ToList(); + i.item_evaluation_round_search = (from x in _repository.Context.eva_performance_plan + orderby x.fiscal_year descending, x.theTime descending + select new external_linkageViewModel { id_guid = x.id, external_name = checkNull(x.theTime) + "/" + checkNull(x.fiscal_year) } + ).ToList(); + return i; + } + public eva_create_evaluation_detail_firstdocWithSelectionViewModel GetBlankItem() { var i = new eva_create_evaluation_detail_firstdocWithSelectionViewModel(); diff --git a/Models/eva_create_evaluation_detail_process/Ieva_create_evaluation_detail_processService.cs b/Models/eva_create_evaluation_detail_process/Ieva_create_evaluation_detail_processService.cs index b1b8e99..c4e6a7e 100644 --- a/Models/eva_create_evaluation_detail_process/Ieva_create_evaluation_detail_processService.cs +++ b/Models/eva_create_evaluation_detail_process/Ieva_create_evaluation_detail_processService.cs @@ -14,10 +14,9 @@ namespace TodoAPI2.Models { List GetListBycreate_evaluation_id(int? create_evaluation_id, int? emp_id, string path); List GetListBySearch(eva_create_evaluation_detail_processSearchModel model, int? emp_id, string path); - eva_create_evaluation_detail_processWithSelectionViewModel GetWithSelection(int id, int? emp_id, string path); eva_create_evaluation_detail_processWithSelectionViewModel GetBlankItem(); - + eva_create_evaluation_detail_processWithSelectionViewModel GetBlankItemWithEmp(int? emp_id); eva_create_evaluation_detail_processWithSelectionViewModel Get(int id, int? emp_id, string path); DataContext GetDataContext(); } diff --git a/Models/eva_create_evaluation_detail_process/eva_create_evaluation_detail_processService.cs b/Models/eva_create_evaluation_detail_process/eva_create_evaluation_detail_processService.cs index ae64442..e6cd364 100644 --- a/Models/eva_create_evaluation_detail_process/eva_create_evaluation_detail_processService.cs +++ b/Models/eva_create_evaluation_detail_process/eva_create_evaluation_detail_processService.cs @@ -218,18 +218,74 @@ namespace TodoAPI2.Models public eva_create_evaluation_detail_processWithSelectionViewModel GetWithSelection(int id, int? emp_id, string path) { var item = Get(id, emp_id, path); - item.item_org_id = ext.GetDepartmentData(); + + var dep = (from x in emp.GetAllEmployee() + where x.id == emp_id + select x.department_id).FirstOrDefault(); + var alldep = (from x in emp.GetDeptMapping() + where x.id == dep || x.id2 == dep + select x.id); + var alleva = (from x in _repository.Context.eva_create_evaluation + join y in _repository.Context.eva_create_evaluation_detail on x.id equals y.create_evaluation_id + where x.employee_id == emp_id + || x.supervisor1_id == emp_id + || x.supervisor2_id == emp_id + || y.chief == emp_id + || y.eva_employee_id == emp_id + || y.supervisor1_id == emp_id + || y.supervisor2_id == emp_id + select y.employee_id).ToList(); + + item.item_org_id = (from i in ext.GetDepartmentData() where alldep.Contains(i.id) select i).ToList(); item.item_level_score = (from i in _repository.Context.eva_level_score - orderby i.min_score - select Mapper.Map(i)).ToList(); - item.item_employee_id = (from x in emp.GetAllEmployee() where x.count_resigns == 0 && x.workingstatus != "คณะกรรมการเนติบัณฑิตยสภา" select x).ToList(); + orderby i.min_score + select Mapper.Map(i)).ToList(); + item.item_employee_id = (from x in emp.GetAllEmployee() + where x.count_resigns == 0 && x.workingstatus != "คณะกรรมการเนติบัณฑิตยสภา" + && alleva.Contains(x.id) + orderby x.fullname + select x).ToList(); item.item_evaluation_round_search = (from x in _repository.Context.eva_performance_plan orderby x.fiscal_year descending, x.theTime descending select new external_linkageViewModel { id_guid = x.id, external_name = checkNull(x.theTime) + "/" + checkNull(x.fiscal_year) } ).ToList(); - return item; } + + public eva_create_evaluation_detail_processWithSelectionViewModel GetBlankItemWithEmp(int? emp_id) + { + var i = new eva_create_evaluation_detail_processWithSelectionViewModel(); + var dep = (from x in emp.GetAllEmployee() + where x.id == emp_id + select x.department_id).FirstOrDefault(); + var alldep = (from x in emp.GetDeptMapping() + where x.id == dep || x.id2 == dep + select x.id); + var alleva = (from x in _repository.Context.eva_create_evaluation + join y in _repository.Context.eva_create_evaluation_detail on x.id equals y.create_evaluation_id + where x.employee_id == emp_id + || x.supervisor1_id == emp_id + || x.supervisor2_id == emp_id + || y.chief == emp_id + || y.eva_employee_id == emp_id + || y.supervisor1_id == emp_id + || y.supervisor2_id == emp_id + select y.employee_id).ToList(); + + i.item_org_id = (from q in ext.GetDepartmentData() where alldep.Contains(q.id) select q).ToList(); + i.item_employee_id = (from x in emp.GetAllEmployee() + where x.count_resigns == 0 && x.workingstatus != "คณะกรรมการเนติบัณฑิตยสภา" + && alleva.Contains(x.id) + orderby x.fullname + select x).ToList(); + i.item_evaluation_round_search = (from x in _repository.Context.eva_performance_plan + orderby x.fiscal_year descending, x.theTime descending + select new external_linkageViewModel { id_guid = x.id, external_name = checkNull(x.theTime) + "/" + checkNull(x.fiscal_year) } + ).ToList(); + + return i; + } + public eva_create_evaluation_detail_processWithSelectionViewModel GetBlankItem() { var i = new eva_create_evaluation_detail_processWithSelectionViewModel();