ปรับปรุงเพิ่มเติม ตามที่้น้องเพลงแจ้ง

This commit is contained in:
Nakorn Rientrakrunchai
2021-02-15 18:52:16 +07:00
parent bba1429925
commit 2825bdde24
10 changed files with 62 additions and 140 deletions

View File

@@ -20,14 +20,14 @@ namespace TodoAPI2.Models
public class eva_adjust_postponement_normalService : Ieva_adjust_postponement_normalService
{
private IBaseRepository2<eva_adjust_postponementEntity, int> _repository;
private IMyDatabase db;
private Iexternal_linkageService ext;
private IMyDatabase db;
private Iexternal_linkageService ext;
private Iexternal_employeeService emp;
private Ieva_create_evaluationService create;
private Ieva_adjust_postponement_detail_normalService detail;
private Ieva_adjust_postponement_detail_normal_02Service normal02;
public eva_adjust_postponement_normalService(IBaseRepository2<eva_adjust_postponementEntity, int> repository, IMyDatabase mydb,
public eva_adjust_postponement_normalService(IBaseRepository2<eva_adjust_postponementEntity, int> repository, IMyDatabase mydb,
Iexternal_linkageService inext,
Iexternal_employeeService inemp,
Ieva_create_evaluationService increate,
@@ -35,8 +35,8 @@ namespace TodoAPI2.Models
Ieva_adjust_postponement_detail_normal_02Service innormal02)
{
_repository = repository;
db = mydb;
ext = inext;
db = mydb;
ext = inext;
emp = inemp;
create = increate;
detail = indetail;
@@ -60,7 +60,7 @@ namespace TodoAPI2.Models
{
return Mapper.Map<List<eva_adjust_postponement_normalViewModel>>(entities);
}
#endregion
#region Public Functions
@@ -84,7 +84,7 @@ namespace TodoAPI2.Models
var temp = create.GetListBySearch(new eva_create_evaluationSearchModel());
i.item_create_evaluation_id = (from x in temp where avaliable_eva.Contains(x.id) select x).ToList();
var all_emp = emp.GetListByemployee_type(null, null);
i.item_managed_by = all_emp.ToList();
i.item_managed_by = all_emp.ToList();
i.item_org_id = (from x in ext.GetDepartmentData() select x).ToList();
@@ -109,19 +109,19 @@ namespace TodoAPI2.Models
public List<eva_adjust_postponement_normalViewModel> GetListByfiscal_year(int? fiscal_year)
{
var model = new eva_adjust_postponement_normalSearchModel();
var model = new eva_adjust_postponement_normalSearchModel();
model.fiscal_year = fiscal_year;
return GetListBySearch(model);
}
public List<eva_adjust_postponement_normalViewModel> GetListBySearch(eva_adjust_postponement_normalSearchModel model)
public List<eva_adjust_postponement_normalViewModel> GetListBySearch(eva_adjust_postponement_normalSearchModel model)
{
var all_emp = emp.GetListByemployee_type(null, null);
var dep = ext.GetDepartmentData();
var avaliable_eva = (from j in _repository.Context.eva_create_evaluation
where j.employee_id == model.emp_id
select j.id).ToList();
where j.employee_id == model.emp_id
select j.id).ToList();
var data = (
from m_eva_adjust_postponement_normal in _repository.Context.eva_adjust_postponement
@@ -134,9 +134,9 @@ namespace TodoAPI2.Models
into external_linkageResult9
from fk_external_linkageResult9 in external_linkageResult9.DefaultIfEmpty()
//join fk_external_linkage10 in dep on fk_eva_create_evaluationResult4. equals fk_external_linkage10.id
//into external_linkageResult10
//from fk_external_linkageResult10 in external_linkageResult10.DefaultIfEmpty()
//join fk_external_linkage10 in dep on fk_eva_create_evaluationResult4. equals fk_external_linkage10.id
//into external_linkageResult10
//from fk_external_linkageResult10 in external_linkageResult10.DefaultIfEmpty()
join fk_eva_performance_plan1 in _repository.Context.eva_performance_plan on fk_eva_create_evaluationResult4.performance_plan_id equals fk_eva_performance_plan1.id
into eva_performance_planResult1
@@ -146,7 +146,7 @@ namespace TodoAPI2.Models
into eva_evaluation_groupResult5
from fk_eva_evaluation_groupResult5 in eva_evaluation_groupResult5.DefaultIfEmpty()
where 1==1
where 1 == 1
&& avaliable_eva.Contains(m_eva_adjust_postponement_normal.create_evaluation_id.Value)
//&& (m_eva_adjust_postponement_normal.id == model.id || !model.id.HasValue)
&& (m_eva_adjust_postponement_normal.fiscal_year == model.fiscal_year || !model.fiscal_year.HasValue)
@@ -192,10 +192,10 @@ namespace TodoAPI2.Models
int? newkey = 0;
var x = (from i in _repository.Context.eva_adjust_postponement
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;
}
@@ -210,7 +210,7 @@ namespace TodoAPI2.Models
detail.ReCreatePostponementDetailNormal(entity);
var inserted = _repository.Insert(entity);
var inserted = _repository.Insert(entity);
return Get(inserted.id);
}
@@ -237,28 +237,28 @@ 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_adjust_postponement_normalInputModel> model)
public string UpdateMultiple(List<eva_adjust_postponement_normalInputModel> 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.fiscal_year = i.fiscal_year;
existingEntity.theDate = i.theDate;
existingEntity.theRound = i.theRound;
existingEntity.create_evaluation_id = i.create_evaluation_id;
existingEntity.limit = i.limit;
existingEntity.limit_frame = i.limit_frame;
existingEntity.limit_quota = i.limit_quota;
existingEntity.percentage = i.percentage;
existingEntity.managed_by = i.managed_by;
//existingEntity.org_id = i.org_id;
existingEntity.fiscal_year = i.fiscal_year;
existingEntity.theDate = i.theDate;
existingEntity.theRound = i.theRound;
existingEntity.create_evaluation_id = i.create_evaluation_id;
existingEntity.limit = i.limit;
existingEntity.limit_frame = i.limit_frame;
existingEntity.limit_quota = i.limit_quota;
existingEntity.percentage = i.percentage;
existingEntity.managed_by = i.managed_by;
//existingEntity.org_id = i.org_id;
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
@@ -271,15 +271,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();
}

View File

@@ -190,7 +190,7 @@ namespace TodoAPI2.Models
int? owner_eva_employee_id = existingEntity.employee_id;
string noti_message = "กรุณาตรวจสอบแบบประเมินของ {0}";
string noti_url = "/eva/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d2?id=" + existingEntity.id.ToString();
bool need_noti = true;
if (model.status_mode == "nextA")
{
@@ -198,7 +198,7 @@ namespace TodoAPI2.Models
existingEntity.status_chief_a_click_date = null;
noti_to_employee_id = existingEntity.chief;
noti_message = "กรุณาตรวจสอบ ข้อตกลงการประเมิน ของ {0}";
noti_url = "/eva/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_firstdoc_d?id=" + existingEntity.id.ToString();
noti_url = "/eva/eva_create_evaluation_detail_firstdocView/eva_create_evaluation_detail_firstdoc_d?id=" + existingEntity.id.ToString();
}
else if (model.status_mode == "backB")
{
@@ -206,7 +206,7 @@ namespace TodoAPI2.Models
existingEntity.status_self_a_click_date = null;
noti_to_employee_id = existingEntity.employee_id;
noti_message = "ข้อตกลงการประเมินของคุณ ({0}) ถูกตีกลับ";
noti_url = "/eva/eva_create_evaluation_detail_agreementView/eva_create_evaluation_detail_firstdoc_d?id=" + existingEntity.id.ToString();
noti_url = "/eva/eva_create_evaluation_detail_firstdocView/eva_create_evaluation_detail_firstdoc_d?id=" + existingEntity.id.ToString();
}
else if (model.status_mode == "nextB")
{
@@ -219,6 +219,7 @@ namespace TodoAPI2.Models
{
noti_to_employee_id = current_eva.employee_id;
}
need_noti = false;
}
else if (model.status_mode == "next0")
{
@@ -286,7 +287,10 @@ namespace TodoAPI2.Models
noti_url = "/eva/eva_create_evaluation_detail_agreementView/eva_create_evaluation_detail_agreement_d2?id=" + existingEntity.id.ToString();
}
SendNotification(noti_to_employee_id, owner_eva_employee_id, existingEntity.id, noti_message, noti_url);
if (need_noti)
{
SendNotification(noti_to_employee_id, owner_eva_employee_id, existingEntity.id, noti_message, noti_url);
}
var updated = _repository.Update(id, existingEntity);
return Get(updated.id);