ปรับปรุงสิทธิการมองเห็นต่างๆ
This commit is contained in:
@@ -12,10 +12,10 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
public interface Ieva_create_evaluation_detail_processService
|
||||
{
|
||||
List<eva_create_evaluation_detail_processViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id);
|
||||
List<eva_create_evaluation_detail_processViewModel> GetListBySearch(eva_create_evaluation_detail_processSearchModel model);
|
||||
List<eva_create_evaluation_detail_processViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id, int? emp_id);
|
||||
List<eva_create_evaluation_detail_processViewModel> GetListBySearch(eva_create_evaluation_detail_processSearchModel model, int? emp_id);
|
||||
|
||||
eva_create_evaluation_detail_processWithSelectionViewModel GetWithSelection(int id);
|
||||
eva_create_evaluation_detail_processWithSelectionViewModel GetWithSelection(int id, int? emp_id);
|
||||
eva_create_evaluation_detail_processWithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace TodoAPI2.Models
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_create_evaluation_detail_processWithSelectionViewModel Get(int id)
|
||||
public eva_create_evaluation_detail_processWithSelectionViewModel Get(int id, int? emp_id)
|
||||
{
|
||||
var allemp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
@@ -100,6 +100,22 @@ namespace TodoAPI2.Models
|
||||
create_evaluation_score1 = fk_eva_create_evaluationResult10.score1,
|
||||
create_evaluation_score2 = fk_eva_create_evaluationResult10.score2,
|
||||
|
||||
status_self = m_eva_create_evaluation_detail_process.status_self,
|
||||
status_chief = m_eva_create_evaluation_detail_process.status_chief,
|
||||
status_supervisor = m_eva_create_evaluation_detail_process.status_supervisor,
|
||||
|
||||
role_code = getRoleCode(emp_id, m_eva_create_evaluation_detail_process.chief,
|
||||
m_eva_create_evaluation_detail_process.chief,
|
||||
fk_eva_create_evaluationResult10.employee_id,
|
||||
fk_eva_create_evaluationResult10.supervisor1_id,
|
||||
fk_eva_create_evaluationResult10.supervisor2_id),
|
||||
|
||||
role_desc = getRoleName(emp_id, m_eva_create_evaluation_detail_process.chief,
|
||||
m_eva_create_evaluation_detail_process.chief,
|
||||
fk_eva_create_evaluationResult10.employee_id,
|
||||
fk_eva_create_evaluationResult10.supervisor1_id,
|
||||
fk_eva_create_evaluationResult10.supervisor2_id),
|
||||
|
||||
isActive = m_eva_create_evaluation_detail_process.isActive,
|
||||
Created = m_eva_create_evaluation_detail_process.created,
|
||||
Updated = m_eva_create_evaluation_detail_process.updated
|
||||
@@ -108,9 +124,9 @@ namespace TodoAPI2.Models
|
||||
|
||||
return data[0];
|
||||
}
|
||||
public eva_create_evaluation_detail_processWithSelectionViewModel GetWithSelection(int id)
|
||||
public eva_create_evaluation_detail_processWithSelectionViewModel GetWithSelection(int id, int? emp_id)
|
||||
{
|
||||
var item = Get(id);
|
||||
var item = Get(id, emp_id);
|
||||
item.item_org_id = ext.GetDepartmentData();
|
||||
item.item_level_score = (from i in _repository.Context.eva_level_score
|
||||
orderby i.min_score
|
||||
@@ -122,21 +138,21 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
var i = new eva_create_evaluation_detail_processWithSelectionViewModel();
|
||||
i.item_org_id = ext.GetDepartmentData();
|
||||
i.item_level_score = (from j in _repository.Context.eva_level_score
|
||||
orderby j.min_score
|
||||
select Mapper.Map<eva_level_scoreViewModel>(i)).ToList();
|
||||
//i.item_level_score = (from j in _repository.Context.eva_level_score
|
||||
// orderby j.min_score
|
||||
// select Mapper.Map<eva_level_scoreViewModel>(i)).ToList();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_processViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id)
|
||||
public List<eva_create_evaluation_detail_processViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id, int? emp_id)
|
||||
{
|
||||
var model = new eva_create_evaluation_detail_processSearchModel();
|
||||
model.create_evaluation_id = create_evaluation_id;
|
||||
return GetListBySearch(model);
|
||||
return GetListBySearch(model, emp_id);
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_processViewModel> GetListBySearch(eva_create_evaluation_detail_processSearchModel model)
|
||||
public List<eva_create_evaluation_detail_processViewModel> GetListBySearch(eva_create_evaluation_detail_processSearchModel model, int? emp_id)
|
||||
{
|
||||
var allemp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
@@ -160,7 +176,13 @@ namespace TodoAPI2.Models
|
||||
&& (fk_external_employee.department_id == model.org_id || !model.org_id.HasValue)
|
||||
&& (fk_external_employee.employee_no == model.search_employee_code || string.IsNullOrEmpty(model.search_employee_code))
|
||||
&& (fk_external_employee.fullname.Contains(model.search_employee_fullname) || string.IsNullOrEmpty(model.search_employee_fullname))
|
||||
|
||||
&& emp_id.HasValue
|
||||
&& (
|
||||
(m_eva_create_evaluation_detail_process.chief.HasValue && emp_id == m_eva_create_evaluation_detail_process.chief)
|
||||
|| (fk_eva_create_evaluationResult10.employee_id.HasValue && emp_id == fk_eva_create_evaluationResult10.employee_id)
|
||||
|| (fk_eva_create_evaluationResult10.supervisor1_id.HasValue && emp_id == fk_eva_create_evaluationResult10.supervisor1_id)
|
||||
|| (fk_eva_create_evaluationResult10.supervisor2_id.HasValue && emp_id == fk_eva_create_evaluationResult10.supervisor2_id)
|
||||
)
|
||||
|
||||
orderby m_eva_create_evaluation_detail_process.created descending
|
||||
select new eva_create_evaluation_detail_processViewModel()
|
||||
@@ -182,6 +204,22 @@ namespace TodoAPI2.Models
|
||||
|
||||
org_id_external_linkage_external_name = fk_external_employee.department_name,
|
||||
|
||||
status_self = m_eva_create_evaluation_detail_process.status_self,
|
||||
status_chief = m_eva_create_evaluation_detail_process.status_chief,
|
||||
status_supervisor = m_eva_create_evaluation_detail_process.status_supervisor,
|
||||
|
||||
role_code = getRoleCode(emp_id, m_eva_create_evaluation_detail_process.chief,
|
||||
m_eva_create_evaluation_detail_process.chief,
|
||||
fk_eva_create_evaluationResult10.employee_id,
|
||||
fk_eva_create_evaluationResult10.supervisor1_id,
|
||||
fk_eva_create_evaluationResult10.supervisor2_id),
|
||||
|
||||
role_desc = getRoleName(emp_id, m_eva_create_evaluation_detail_process.chief,
|
||||
m_eva_create_evaluation_detail_process.chief,
|
||||
fk_eva_create_evaluationResult10.employee_id,
|
||||
fk_eva_create_evaluationResult10.supervisor1_id,
|
||||
fk_eva_create_evaluationResult10.supervisor2_id),
|
||||
|
||||
isActive = m_eva_create_evaluation_detail_process.isActive,
|
||||
Created = m_eva_create_evaluation_detail_process.created,
|
||||
Updated = m_eva_create_evaluation_detail_process.updated
|
||||
@@ -191,6 +229,26 @@ namespace TodoAPI2.Models
|
||||
return data;
|
||||
}
|
||||
|
||||
private string getRoleCode(int? emp_id, int? chief, int? supervisor1, int? supervisor2, int? supervisor1A, int? supervisor2A)
|
||||
{
|
||||
if (emp_id == chief) return "1";
|
||||
else if (emp_id == supervisor1) return "1";
|
||||
else if (emp_id == supervisor2) return "2";
|
||||
else if (emp_id == supervisor1A) return "3";
|
||||
else if (emp_id == supervisor2A) return "4";
|
||||
return "";
|
||||
}
|
||||
|
||||
private string getRoleName(int? emp_id, int? chief, int? supervisor1, int? supervisor2, int? supervisor1A, int? supervisor2A)
|
||||
{
|
||||
if (emp_id == chief) return "ผู้ประเมิน";
|
||||
else if (emp_id == supervisor1) return "ผู้ประเมิน";
|
||||
else if (emp_id == supervisor2) return "ผู้ประเมินสูสุด";
|
||||
else if (emp_id == supervisor1A) return "ผู้บังคับบัญชาเหนือขึ้นไป";
|
||||
else if (emp_id == supervisor2A) return "ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง (สูงสุด)";
|
||||
return "";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@@ -43,5 +43,15 @@ namespace TodoAPI2.Models
|
||||
public Guid? create_evaluation_id_eva_create_evaluation_performance_plan_id { get; set; }
|
||||
public string org_id_external_linkage_external_name { get; set; }
|
||||
|
||||
public string status_self { get; set; }
|
||||
|
||||
public string status_chief { get; set; }
|
||||
|
||||
public string status_supervisor { get; set; }
|
||||
|
||||
public string role_desc { get; set; }
|
||||
|
||||
public string role_code { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -157,6 +157,15 @@ namespace TodoAPI2.Models
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
var current_detail = (from k in _repository.Context.eva_create_evaluation_detail
|
||||
where k.id == model.id
|
||||
select k).FirstOrDefault();
|
||||
|
||||
if (current_detail.status_chief == "Y")
|
||||
{
|
||||
throw new Exception("ผู้ประเมิน ส่งแบบประเมินไปแล้ว บันทึกไม่ได้");
|
||||
}
|
||||
|
||||
existingEntity.create_evaluation_id = model.create_evaluation_id;
|
||||
existingEntity.supervisor1 = model.supervisor1;
|
||||
existingEntity.supervisor1_result = model.supervisor1_result;
|
||||
|
||||
@@ -144,9 +144,7 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
@@ -157,6 +155,15 @@ namespace TodoAPI2.Models
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
var current_detail = (from k in _repository.Context.eva_create_evaluation_detail
|
||||
where k.id == model.id
|
||||
select k).FirstOrDefault();
|
||||
|
||||
if (current_detail.status_supervisor == "Y")
|
||||
{
|
||||
throw new Exception("ผู้ประเมินสูงสุด ส่งแบบประเมินไปแล้ว บันทึกไม่ได้");
|
||||
}
|
||||
|
||||
existingEntity.create_evaluation_id = model.create_evaluation_id;
|
||||
existingEntity.supervisor2 = model.supervisor2;
|
||||
existingEntity.supervisor2_result = model.supervisor2_result;
|
||||
|
||||
@@ -157,6 +157,15 @@ namespace TodoAPI2.Models
|
||||
throw new Exception("ไม่สามารถบันทึกค่าน้ำหนักในส่วนผลสัมฤทธิ์ของงาน ได้เกิน 100");
|
||||
}
|
||||
|
||||
var current_detail = (from i in _repository.Context.eva_create_evaluation_detail
|
||||
where i.id == model.create_evaluation_detail_id
|
||||
select i).FirstOrDefault();
|
||||
|
||||
if(current_detail.status_self == "Y")
|
||||
{
|
||||
throw new Exception("คุณนำส่งข้อตกลงการประเมินไปแล้ว ไม่สามารถบันทึกได้");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(model.thefile))
|
||||
{
|
||||
//Move file from temp to physical
|
||||
@@ -185,6 +194,15 @@ namespace TodoAPI2.Models
|
||||
throw new Exception("ไม่สามารถบันทึกค่าน้ำหนักในส่วนผลสัมฤทธิ์ของงาน ได้เกิน 100");
|
||||
}
|
||||
|
||||
var current_detail = (from i in _repository.Context.eva_create_evaluation_detail
|
||||
where i.id == model.create_evaluation_detail_id
|
||||
select i).FirstOrDefault();
|
||||
|
||||
if (current_detail.status_self == "Y")
|
||||
{
|
||||
throw new Exception("คุณนำส่งข้อตกลงการประเมินไปแล้ว ไม่สามารถบันทึกได้");
|
||||
}
|
||||
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
@@ -231,6 +249,15 @@ namespace TodoAPI2.Models
|
||||
var existingEntity = _repository.Get(i.id.Value);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
var current_detail = (from k in _repository.Context.eva_create_evaluation_detail
|
||||
where k.id == existingEntity.create_evaluation_detail_id
|
||||
select k).FirstOrDefault();
|
||||
|
||||
if (current_detail.status_self == "Y")
|
||||
{
|
||||
throw new Exception("ผู้รับการประเมิน ส่งแบบประเมินไปแล้ว บันทึกไม่ได้");
|
||||
}
|
||||
|
||||
existingEntity.create_evaluation_detail_id = i.create_evaluation_detail_id;
|
||||
existingEntity.achievement = i.achievement;
|
||||
existingEntity.weight = i.weight;
|
||||
|
||||
@@ -156,6 +156,15 @@ namespace TodoAPI2.Models
|
||||
|
||||
public eva_evaluation_achievement_processViewModel Update(int id, eva_evaluation_achievement_processInputModel model)
|
||||
{
|
||||
var current_detail = (from i in _repository.Context.eva_create_evaluation_detail
|
||||
where i.id == model.create_evaluation_detail_id
|
||||
select i).FirstOrDefault();
|
||||
|
||||
if (current_detail.status_chief == "Y")
|
||||
{
|
||||
throw new Exception("ผู้ประเมิน ส่งแบบประเมินไปแล้ว บันทึกไม่ได้");
|
||||
}
|
||||
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
@@ -186,6 +195,16 @@ namespace TodoAPI2.Models
|
||||
if (i.active_mode == "1" && i.id.HasValue) // update
|
||||
{
|
||||
var existingEntity = _repository.Get(i.id.Value);
|
||||
|
||||
var current_detail = (from k in _repository.Context.eva_create_evaluation_detail
|
||||
where k.id == existingEntity.create_evaluation_detail_id
|
||||
select k).FirstOrDefault();
|
||||
|
||||
if (current_detail.status_chief == "Y")
|
||||
{
|
||||
throw new Exception("ผู้ประเมิน ส่งแบบประเมินไปแล้ว บันทึกไม่ได้");
|
||||
}
|
||||
|
||||
if (existingEntity != null)
|
||||
{
|
||||
//existingEntity.create_evaluation_detail_id = i.create_evaluation_detail_id;
|
||||
|
||||
@@ -20,14 +20,14 @@ namespace TodoAPI2.Models
|
||||
public class eva_evaluation_achievement_process2Service : Ieva_evaluation_achievement_process2Service
|
||||
{
|
||||
private IBaseRepository2<eva_evaluation_achievementEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
|
||||
public eva_evaluation_achievement_process2Service(IBaseRepository2<eva_evaluation_achievementEntity, int> repository, IMyDatabase mydb, Iexternal_linkageService inext)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
@@ -47,7 +47,7 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
return Mapper.Map<List<eva_evaluation_achievement_process2ViewModel>>(entities);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
@@ -77,12 +77,12 @@ namespace TodoAPI2.Models
|
||||
|
||||
public List<eva_evaluation_achievement_process2ViewModel> GetListBycreate_evaluation_detail_id(int? create_evaluation_detail_id)
|
||||
{
|
||||
var model = new eva_evaluation_achievement_process2SearchModel();
|
||||
var model = new eva_evaluation_achievement_process2SearchModel();
|
||||
model.create_evaluation_detail_id = create_evaluation_detail_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_evaluation_achievement_process2ViewModel> GetListBySearch(eva_evaluation_achievement_process2SearchModel model)
|
||||
public List<eva_evaluation_achievement_process2ViewModel> GetListBySearch(eva_evaluation_achievement_process2SearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_evaluation_achievement_process2 in _repository.Context.eva_evaluation_achievement
|
||||
@@ -92,7 +92,7 @@ namespace TodoAPI2.Models
|
||||
from fk_eva_create_evaluation_detailResult1 in eva_create_evaluation_detailResult1.DefaultIfEmpty()
|
||||
|
||||
|
||||
where 1==1
|
||||
where 1 == 1
|
||||
//&& (m_eva_evaluation_achievement_process2.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_evaluation_achievement_process2.create_evaluation_detail_id == model.create_evaluation_detail_id || !model.create_evaluation_detail_id.HasValue)
|
||||
|
||||
@@ -135,10 +135,10 @@ namespace TodoAPI2.Models
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_evaluation_achievement
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if(x.Count > 0)
|
||||
if (x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
@@ -160,7 +160,7 @@ namespace TodoAPI2.Models
|
||||
}
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
@@ -174,21 +174,21 @@ namespace TodoAPI2.Models
|
||||
existingEntity.weight = model.weight;
|
||||
if (!string.IsNullOrEmpty(model.thefile))
|
||||
{
|
||||
if (model.thefile.StartsWith("Uploads"))
|
||||
{
|
||||
var thefileFileName = FileUtil.MoveTempUploadFileToActualPath(
|
||||
if (model.thefile.StartsWith("Uploads"))
|
||||
{
|
||||
var thefileFileName = FileUtil.MoveTempUploadFileToActualPath(
|
||||
model.thefile, FilePathConstant.DirType.FilesTestUpload, existingEntity.id, existingEntity.thefile);
|
||||
existingEntity.thefile = thefileFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
existingEntity.thefile = model.thefile;
|
||||
}
|
||||
existingEntity.thefile = thefileFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
existingEntity.thefile = model.thefile;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
existingEntity.thefile = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
existingEntity.thefile = null;
|
||||
}
|
||||
|
||||
//existingEntity.score = model.score;
|
||||
existingEntity.score2 = model.score2;
|
||||
@@ -204,38 +204,48 @@ namespace TodoAPI2.Models
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_evaluation_achievement_process2InputModel> model)
|
||||
public string UpdateMultiple(List<eva_evaluation_achievement_process2InputModel> model)
|
||||
{
|
||||
foreach(var i in model)
|
||||
foreach (var i in model)
|
||||
{
|
||||
if (i.active_mode == "1" && i.id.HasValue) // update
|
||||
{
|
||||
{
|
||||
var existingEntity = _repository.Get(i.id.Value);
|
||||
|
||||
var current_detail = (from k in _repository.Context.eva_create_evaluation_detail
|
||||
where k.id == existingEntity.create_evaluation_detail_id
|
||||
select k).FirstOrDefault();
|
||||
|
||||
if (current_detail.status_supervisor == "Y")
|
||||
{
|
||||
throw new Exception("ผู้ประเมินสูงสุด ส่งแบบประเมินไปแล้ว บันทึกไม่ได้");
|
||||
}
|
||||
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.create_evaluation_detail_id = i.create_evaluation_detail_id;
|
||||
existingEntity.achievement = i.achievement;
|
||||
existingEntity.weight = i.weight;
|
||||
if (!string.IsNullOrEmpty(i.thefile))
|
||||
{
|
||||
if (i.thefile.StartsWith("Uploads"))
|
||||
{
|
||||
var thefileFileName = FileUtil.MoveTempUploadFileToActualPath(
|
||||
i.thefile, FilePathConstant.DirType.FilesTestUpload, existingEntity.id, existingEntity.thefile);
|
||||
existingEntity.thefile = thefileFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
existingEntity.thefile = i.thefile;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
existingEntity.thefile = null;
|
||||
}
|
||||
existingEntity.create_evaluation_detail_id = i.create_evaluation_detail_id;
|
||||
existingEntity.achievement = i.achievement;
|
||||
existingEntity.weight = i.weight;
|
||||
if (!string.IsNullOrEmpty(i.thefile))
|
||||
{
|
||||
if (i.thefile.StartsWith("Uploads"))
|
||||
{
|
||||
var thefileFileName = FileUtil.MoveTempUploadFileToActualPath(
|
||||
i.thefile, FilePathConstant.DirType.FilesTestUpload, existingEntity.id, existingEntity.thefile);
|
||||
existingEntity.thefile = thefileFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
existingEntity.thefile = i.thefile;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
existingEntity.thefile = null;
|
||||
}
|
||||
|
||||
//existingEntity.score = i.score;
|
||||
existingEntity.score2 = i.score2;
|
||||
@@ -257,15 +267,15 @@ namespace TodoAPI2.Models
|
||||
_repository.InsertWithoutCommit(entity);
|
||||
}
|
||||
else if (i.active_mode == "0" && i.id.HasValue) // remove
|
||||
{
|
||||
{
|
||||
_repository.DeleteWithoutCommit(i.id.Value);
|
||||
}
|
||||
else if (i.active_mode == "0" && !i.id.HasValue)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
_repository.Context.SaveChanges();
|
||||
_repository.Context.SaveChanges();
|
||||
|
||||
return model.Count().ToString();
|
||||
}
|
||||
|
||||
@@ -20,14 +20,14 @@ namespace TodoAPI2.Models
|
||||
public class eva_evaluation_behaviorService : Ieva_evaluation_behaviorService
|
||||
{
|
||||
private IBaseRepository2<eva_evaluation_behaviorEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
|
||||
public eva_evaluation_behaviorService(IBaseRepository2<eva_evaluation_behaviorEntity, int> repository, IMyDatabase mydb, Iexternal_linkageService inext)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
@@ -47,7 +47,7 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
return Mapper.Map<List<eva_evaluation_behaviorViewModel>>(entities);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
@@ -77,12 +77,12 @@ namespace TodoAPI2.Models
|
||||
|
||||
public List<eva_evaluation_behaviorViewModel> GetListBycreate_evaluation_detail_id(int? create_evaluation_detail_id)
|
||||
{
|
||||
var model = new eva_evaluation_behaviorSearchModel();
|
||||
var model = new eva_evaluation_behaviorSearchModel();
|
||||
model.create_evaluation_detail_id = create_evaluation_detail_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_evaluation_behaviorViewModel> GetListBySearch(eva_evaluation_behaviorSearchModel model)
|
||||
public List<eva_evaluation_behaviorViewModel> GetListBySearch(eva_evaluation_behaviorSearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_evaluation_behavior in _repository.Context.eva_evaluation_behavior
|
||||
@@ -92,7 +92,7 @@ namespace TodoAPI2.Models
|
||||
from fk_eva_create_evaluation_detailResult1 in eva_create_evaluation_detailResult1.DefaultIfEmpty()
|
||||
|
||||
|
||||
where 1==1
|
||||
where 1 == 1
|
||||
&& (m_eva_evaluation_behavior.create_evaluation_detail_id == model.create_evaluation_detail_id || !model.create_evaluation_detail_id.HasValue)
|
||||
|
||||
|
||||
@@ -124,10 +124,10 @@ namespace TodoAPI2.Models
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_evaluation_behavior
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if(x.Count > 0)
|
||||
if (x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
@@ -149,8 +149,17 @@ namespace TodoAPI2.Models
|
||||
throw new Exception("ไม่สามารถบันทึกค่าน้ำหนักในส่วนผลสัมฤทธิ์ของงาน ได้เกิน 100");
|
||||
}
|
||||
|
||||
var current_detail = (from i in _repository.Context.eva_create_evaluation_detail
|
||||
where i.id == model.create_evaluation_detail_id
|
||||
select i).FirstOrDefault();
|
||||
|
||||
if (current_detail.status_self == "Y")
|
||||
{
|
||||
throw new Exception("คุณนำส่งข้อตกลงการประเมินไปแล้ว ไม่สามารถบันทึกได้");
|
||||
}
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
@@ -169,6 +178,15 @@ namespace TodoAPI2.Models
|
||||
throw new Exception("ไม่สามารถบันทึกค่าน้ำหนักในส่วนพฤติกรรมการปฏิบัติงาน ได้เกิน 100");
|
||||
}
|
||||
|
||||
var current_detail = (from i in _repository.Context.eva_create_evaluation_detail
|
||||
where i.id == model.create_evaluation_detail_id
|
||||
select i).FirstOrDefault();
|
||||
|
||||
if (current_detail.status_self == "Y")
|
||||
{
|
||||
throw new Exception("คุณนำส่งข้อตกลงการประเมินไปแล้ว ไม่สามารถบันทึกได้");
|
||||
}
|
||||
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
@@ -181,21 +199,30 @@ namespace TodoAPI2.Models
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_evaluation_behaviorInputModel> model)
|
||||
public string UpdateMultiple(List<eva_evaluation_behaviorInputModel> model)
|
||||
{
|
||||
foreach(var i in model)
|
||||
foreach (var i in model)
|
||||
{
|
||||
if (i.active_mode == "1" && i.id.HasValue) // update
|
||||
{
|
||||
{
|
||||
var existingEntity = _repository.Get(i.id.Value);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.create_evaluation_detail_id = i.create_evaluation_detail_id;
|
||||
existingEntity.behavior = i.behavior;
|
||||
existingEntity.weight = i.weight;
|
||||
var current_detail = (from k in _repository.Context.eva_create_evaluation_detail
|
||||
where k.id == existingEntity.create_evaluation_detail_id
|
||||
select k).FirstOrDefault();
|
||||
|
||||
if (current_detail.status_self == "Y")
|
||||
{
|
||||
throw new Exception("ผู้รับการประเมิน ส่งแบบประเมินไปแล้ว บันทึกไม่ได้");
|
||||
}
|
||||
|
||||
existingEntity.create_evaluation_detail_id = i.create_evaluation_detail_id;
|
||||
existingEntity.behavior = i.behavior;
|
||||
existingEntity.weight = i.weight;
|
||||
|
||||
|
||||
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
|
||||
@@ -208,15 +235,15 @@ namespace TodoAPI2.Models
|
||||
_repository.InsertWithoutCommit(entity);
|
||||
}
|
||||
else if (i.active_mode == "0" && i.id.HasValue) // remove
|
||||
{
|
||||
{
|
||||
_repository.DeleteWithoutCommit(i.id.Value);
|
||||
}
|
||||
else if (i.active_mode == "0" && !i.id.HasValue)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
_repository.Context.SaveChanges();
|
||||
_repository.Context.SaveChanges();
|
||||
|
||||
return model.Count().ToString();
|
||||
}
|
||||
|
||||
@@ -193,6 +193,15 @@ namespace TodoAPI2.Models
|
||||
var existingEntity = _repository.Get(i.id.Value);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
var current_detail = (from k in _repository.Context.eva_create_evaluation_detail
|
||||
where k.id == existingEntity.create_evaluation_detail_id
|
||||
select k).FirstOrDefault();
|
||||
|
||||
if (current_detail.status_chief == "Y")
|
||||
{
|
||||
throw new Exception("ผู้ประเมิน ส่งแบบประเมินไปแล้ว บันทึกไม่ได้");
|
||||
}
|
||||
|
||||
//existingEntity.create_evaluation_detail_id = i.create_evaluation_detail_id;
|
||||
//existingEntity.behavior = i.behavior;
|
||||
//existingEntity.weight = i.weight;
|
||||
|
||||
@@ -190,6 +190,15 @@ namespace TodoAPI2.Models
|
||||
var existingEntity = _repository.Get(i.id.Value);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
var current_detail = (from k in _repository.Context.eva_create_evaluation_detail
|
||||
where k.id == existingEntity.create_evaluation_detail_id
|
||||
select k).FirstOrDefault();
|
||||
|
||||
if (current_detail.status_supervisor == "Y")
|
||||
{
|
||||
throw new Exception("ผู้ประเมินสูงสุด ส่งแบบประเมินไปแล้ว บันทึกไม่ได้");
|
||||
}
|
||||
|
||||
//existingEntity.create_evaluation_detail_id = i.create_evaluation_detail_id;
|
||||
//existingEntity.behavior = i.behavior;
|
||||
//existingEntity.weight = i.weight;
|
||||
|
||||
Reference in New Issue
Block a user