ปรับปรุงส่วน ตารางกำหนดช่วงร้อยละที่ได้เลื่อน
This commit is contained in:
@@ -105,22 +105,22 @@ namespace TodoAPI2.Models
|
||||
private void ReloadPostponement(int? adjust_postponement_id)
|
||||
{
|
||||
var rawData = from i in _repository.Context.eva_adjust_postponement_detail
|
||||
where i.adjust_postponement_id == adjust_postponement_id
|
||||
select i;
|
||||
where i.adjust_postponement_id == adjust_postponement_id
|
||||
select i;
|
||||
|
||||
var baseScore = from i in _repository.Context.eva_adjust_postponement_detail
|
||||
join j in _repository.Context.eva_adjust_postponement on i.adjust_postponement_id equals j.id
|
||||
join k in _repository.Context.eva_create_evaluation on j.create_evaluation_id equals k.id
|
||||
join m in _repository.Context.eva_create_evaluation_detail on k.id equals m.create_evaluation_id
|
||||
where i.adjust_postponement_id == adjust_postponement_id
|
||||
&& m.employee_id == i.employee_id
|
||||
select m;
|
||||
join j in _repository.Context.eva_adjust_postponement on i.adjust_postponement_id equals j.id
|
||||
join k in _repository.Context.eva_create_evaluation on j.create_evaluation_id equals k.id
|
||||
join m in _repository.Context.eva_create_evaluation_detail on k.id equals m.create_evaluation_id
|
||||
where i.adjust_postponement_id == adjust_postponement_id
|
||||
&& m.employee_id == i.employee_id
|
||||
select m;
|
||||
|
||||
foreach(var x in rawData)
|
||||
foreach (var x in rawData)
|
||||
{
|
||||
var y = (from i in baseScore
|
||||
where i.employee_id == x.employee_id
|
||||
select getData(i)).FirstOrDefault();
|
||||
where i.employee_id == x.employee_id
|
||||
select getData(i)).FirstOrDefault();
|
||||
x.level_score_final = y.Item2;
|
||||
x.score_final = y.Item1;
|
||||
}
|
||||
@@ -154,7 +154,7 @@ namespace TodoAPI2.Models
|
||||
var item = (from i in level_detail
|
||||
where i.min_value <= score && i.max_value >= score
|
||||
select i).FirstOrDefault();
|
||||
if(item != null)
|
||||
if (item != null)
|
||||
{
|
||||
return (item.min_percentage, item.max_percentage);
|
||||
}
|
||||
@@ -163,8 +163,14 @@ namespace TodoAPI2.Models
|
||||
|
||||
public List<eva_adjust_postponement_detail_normal_02ViewModel> GetListBySearch(eva_adjust_postponement_detail_normal_02SearchModel model)
|
||||
{
|
||||
var theGroup = (from i in _repository.Context.eva_adjust_postponement
|
||||
join j in _repository.Context.eva_create_evaluation on i.create_evaluation_id equals j.id
|
||||
where i.id == model.adjust_postponement_id
|
||||
select j.evaluation_group_id).FirstOrDefault();
|
||||
|
||||
var level_detail = (from i in _repository.Context.eva_level_score_detail
|
||||
select i).ToList();
|
||||
where i.group_guid == theGroup
|
||||
select i).ToList();
|
||||
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
@@ -174,10 +180,10 @@ namespace TodoAPI2.Models
|
||||
into eva_adjust_postponementResult1
|
||||
from fk_eva_adjust_postponementResult1 in eva_adjust_postponementResult1.DefaultIfEmpty()
|
||||
|
||||
//join create_detail in _repository.Context.eva_create_evaluation_detail
|
||||
// on fk_eva_adjust_postponementResult1.create_evaluation_id equals create_detail.create_evaluation_id
|
||||
// into create_detailResult
|
||||
//from fk_create_detailResult in create_detailResult.DefaultIfEmpty()
|
||||
//join create_detail in _repository.Context.eva_create_evaluation_detail
|
||||
// on fk_eva_adjust_postponementResult1.create_evaluation_id equals create_detail.create_evaluation_id
|
||||
// into create_detailResult
|
||||
//from fk_create_detailResult in create_detailResult.DefaultIfEmpty()
|
||||
|
||||
join create_data in _repository.Context.eva_create_evaluation
|
||||
on fk_eva_adjust_postponementResult1.create_evaluation_id equals create_data.id
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace TodoAPI2.Models
|
||||
|
||||
[ForeignKey("level_score_id")]
|
||||
public eva_level_scoreEntity eva_level_score_level_score_id { get; set; }
|
||||
public Guid level_score_id { get; set; }
|
||||
public Guid? level_score_id { get; set; }
|
||||
|
||||
public decimal? min_value { get; set; }
|
||||
|
||||
@@ -28,8 +28,10 @@ namespace TodoAPI2.Models
|
||||
|
||||
public decimal? max_percentage { get; set; }
|
||||
|
||||
|
||||
public void SetAutoField(DataContext context)
|
||||
[ForeignKey("group_guid")]
|
||||
public eva_evaluation_groupEntity eva_evaluation_group_group_guid { get; set; }
|
||||
public Guid? group_guid { get; set; }
|
||||
public void SetAutoField(DataContext context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace TodoAPI2.Models
|
||||
|
||||
public Guid? id { get; set; }
|
||||
|
||||
public Guid level_score_id { get; set; }
|
||||
public Guid? level_score_id { get; set; }
|
||||
|
||||
public decimal? min_value { get; set; }
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace TodoAPI2.Models
|
||||
|
||||
public decimal? max_percentage { get; set; }
|
||||
|
||||
public Guid? group_guid { get; set; }
|
||||
|
||||
public string active_mode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@ namespace TodoAPI2.Models
|
||||
|
||||
public Guid id { get; set; }
|
||||
|
||||
public Guid level_score_id { get; set; }
|
||||
public Guid? level_score_id { get; set; }
|
||||
|
||||
public Guid? group_guid { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,14 +20,14 @@ namespace TodoAPI2.Models
|
||||
public class eva_level_score_detailService : Ieva_level_score_detailService
|
||||
{
|
||||
private IBaseRepository2<eva_level_score_detailEntity, Guid> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
|
||||
public eva_level_score_detailService(IBaseRepository2<eva_level_score_detailEntity, Guid> 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_level_score_detailViewModel>>(entities);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
@@ -76,26 +76,26 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_level_score_detailWithSelectionViewModel>(entity);
|
||||
|
||||
i.item_level_score_id = (from x in _repository.Context.eva_level_score select x).ToList();
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_level_score_detailWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_level_score_detailWithSelectionViewModel();
|
||||
|
||||
i.item_level_score_id = (from x in _repository.Context.eva_level_score select x).ToList();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_level_score_detailViewModel> GetListBylevel_score_id(Guid level_score_id)
|
||||
{
|
||||
var model = new eva_level_score_detailSearchModel();
|
||||
var model = new eva_level_score_detailSearchModel();
|
||||
model.level_score_id = level_score_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_level_score_detailViewModel> GetListBySearch(eva_level_score_detailSearchModel model)
|
||||
public List<eva_level_score_detailViewModel> GetListBySearch(eva_level_score_detailSearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_level_score_detail in _repository.Context.eva_level_score_detail
|
||||
@@ -104,11 +104,14 @@ namespace TodoAPI2.Models
|
||||
into eva_level_scoreResult1
|
||||
from fk_eva_level_scoreResult1 in eva_level_scoreResult1.DefaultIfEmpty()
|
||||
|
||||
join fk_eva_evaluation_group6 in _repository.Context.eva_evaluation_group on m_eva_level_score_detail.group_guid equals fk_eva_evaluation_group6.id
|
||||
into eva_evaluation_groupResult6
|
||||
from fk_eva_evaluation_groupResult6 in eva_evaluation_groupResult6.DefaultIfEmpty()
|
||||
|
||||
where
|
||||
1 == 1
|
||||
&& (m_eva_level_score_detail.level_score_id == model.level_score_id)
|
||||
|
||||
where
|
||||
1 == 1
|
||||
&& (!model.level_score_id.HasValue || m_eva_level_score_detail.level_score_id == model.level_score_id)
|
||||
&& (m_eva_level_score_detail.group_guid == model.group_guid)
|
||||
|
||||
orderby m_eva_level_score_detail.min_value descending
|
||||
select new eva_level_score_detailViewModel()
|
||||
@@ -119,8 +122,10 @@ namespace TodoAPI2.Models
|
||||
max_value = m_eva_level_score_detail.max_value,
|
||||
min_percentage = m_eva_level_score_detail.min_percentage,
|
||||
max_percentage = m_eva_level_score_detail.max_percentage,
|
||||
group_guid = m_eva_level_score_detail.group_guid,
|
||||
|
||||
level_score_id_eva_level_score_code = fk_eva_level_scoreResult1.code,
|
||||
level_score_id_eva_level_score_code = fk_eva_level_scoreResult1.detail,
|
||||
group_guid_eva_evaluation_group_code = fk_eva_evaluation_groupResult6.thegroup,
|
||||
|
||||
isActive = m_eva_level_score_detail.isActive,
|
||||
Created = m_eva_level_score_detail.created,
|
||||
@@ -143,8 +148,8 @@ namespace TodoAPI2.Models
|
||||
entity.id = Guid.NewGuid();
|
||||
|
||||
|
||||
entity.SetAutoField(_repository.Context);
|
||||
|
||||
entity.SetAutoField(_repository.Context);
|
||||
|
||||
if (is_force_save)
|
||||
{
|
||||
var inserted = _repository.Insert(entity);
|
||||
@@ -169,8 +174,9 @@ namespace TodoAPI2.Models
|
||||
existingEntity.max_value = model.max_value;
|
||||
existingEntity.min_percentage = model.min_percentage;
|
||||
existingEntity.max_percentage = model.max_percentage;
|
||||
existingEntity.group_guid = model.group_guid;
|
||||
|
||||
existingEntity.SetAutoField(_repository.Context);
|
||||
existingEntity.SetAutoField(_repository.Context);
|
||||
|
||||
if (is_force_save)
|
||||
{
|
||||
@@ -186,25 +192,26 @@ namespace TodoAPI2.Models
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_level_score_detailInputModel> model, bool is_force_save)
|
||||
public string UpdateMultiple(List<eva_level_score_detailInputModel> model, bool is_force_save)
|
||||
{
|
||||
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.level_score_id = i.level_score_id;
|
||||
existingEntity.min_value = i.min_value;
|
||||
existingEntity.max_value = i.max_value;
|
||||
existingEntity.min_percentage = i.min_percentage;
|
||||
existingEntity.max_percentage = i.max_percentage;
|
||||
existingEntity.level_score_id = i.level_score_id;
|
||||
existingEntity.min_value = i.min_value;
|
||||
existingEntity.max_value = i.max_value;
|
||||
existingEntity.min_percentage = i.min_percentage;
|
||||
existingEntity.max_percentage = i.max_percentage;
|
||||
existingEntity.group_guid = i.group_guid;
|
||||
|
||||
existingEntity.SetAutoField(_repository.Context);
|
||||
existingEntity.SetAutoField(_repository.Context);
|
||||
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
|
||||
}
|
||||
}
|
||||
@@ -212,22 +219,22 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
var entity = GetEntity(i);
|
||||
entity.id = Guid.NewGuid();
|
||||
entity.SetAutoField(_repository.Context);
|
||||
entity.SetAutoField(_repository.Context);
|
||||
_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
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_force_save)
|
||||
{
|
||||
_repository.Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
return model.Count().ToString();
|
||||
}
|
||||
@@ -251,7 +258,7 @@ namespace TodoAPI2.Models
|
||||
return;
|
||||
}
|
||||
|
||||
public void RefreshAutoFieldOfAllData()
|
||||
public void RefreshAutoFieldOfAllData()
|
||||
{
|
||||
var all_items = from i in _repository.Context.eva_level_score_detail
|
||||
select i;
|
||||
@@ -262,17 +269,18 @@ namespace TodoAPI2.Models
|
||||
_repository.Context.SaveChanges();
|
||||
}
|
||||
|
||||
private Dictionary<string,string> GetLookupForLog()
|
||||
private Dictionary<string, string> GetLookupForLog()
|
||||
{
|
||||
var i = new Dictionary<string, string>();
|
||||
|
||||
|
||||
i.Add("level_score_id", "level_score_id");
|
||||
i.Add("level_score_id_eva_level_score_code", "level_score_id");
|
||||
i.Add("min_value", "ช่วงคะแนนต่ำสุด");
|
||||
i.Add("max_value", "ช่วงคะแนนสูงสุด");
|
||||
i.Add("min_percentage", "ร้อยละที่ได้เลื่อนต่ำสุด");
|
||||
i.Add("max_percentage", "ร้อยละที่ได้เลื่อนสูงสุด");
|
||||
i.Add("max_percentage", "ร้อยละที่ได้เลื่อนสูงสุด");
|
||||
i.Add("group_guid", "กลุ่มการประเมิน");
|
||||
i.Add("group_guid_eva_evaluation_group_code", "กลุ่มการประเมิน");
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace TodoAPI2.Models
|
||||
public class eva_level_score_detailViewModel : BaseViewModel2<Guid>
|
||||
{
|
||||
|
||||
public Guid level_score_id { get; set; }
|
||||
public Guid? level_score_id { get; set; }
|
||||
|
||||
public decimal? min_value { get; set; }
|
||||
|
||||
@@ -24,7 +24,10 @@ namespace TodoAPI2.Models
|
||||
|
||||
public decimal? max_percentage { get; set; }
|
||||
|
||||
public Guid? group_guid { get; set; }
|
||||
|
||||
public string level_score_id_eva_level_score_code { get; set; }
|
||||
public string group_guid_eva_evaluation_group_code { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,6 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_level_score_detailWithSelectionViewModel: eva_level_score_detailViewModel
|
||||
{
|
||||
|
||||
public List<eva_level_scoreEntity> item_level_score_id { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user