ปรับปรุงสิทธิการมองเห็นต่างๆ
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user