ปรับปรุงเฉพาะส่วนที่เกี่ยวกับรายงาน และการประมวลผล
This commit is contained in:
@@ -22,12 +22,15 @@ namespace TodoAPI2.Models
|
||||
private IBaseRepository2<eva_limit_frame_groupEntity, Guid> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
|
||||
public eva_limit_frame_groupService(IBaseRepository2<eva_limit_frame_groupEntity, Guid> repository, IMyDatabase mydb, Iexternal_linkageService inext)
|
||||
public eva_limit_frame_groupService(IBaseRepository2<eva_limit_frame_groupEntity, Guid> repository,
|
||||
IMyDatabase mydb, Iexternal_linkageService inext, Iexternal_employeeService inemp)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
emp = inemp;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
@@ -172,6 +175,18 @@ namespace TodoAPI2.Models
|
||||
public eva_limit_frame_groupViewModel Update(Guid id, eva_limit_frame_groupInputModel model, bool is_force_save)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
|
||||
var plan = (from i in _repository.Context.eva_limit_frame_plan where i.plan_guid == existingEntity.frame_plan_guid select i).FirstOrDefault();
|
||||
|
||||
var all_all_emp = emp.GetAllEmployee();
|
||||
var mapping_dept = emp.GetDeptMapping();
|
||||
var working_record = from i in emp.GetWorkingRecord()
|
||||
// where
|
||||
//plan.executed_date.HasValue
|
||||
//&& i.start_date <= plan.executed_date
|
||||
//&& i.end_date >= plan.executed_date
|
||||
select i;
|
||||
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.frame_plan_guid = model.frame_plan_guid;
|
||||
@@ -182,7 +197,24 @@ namespace TodoAPI2.Models
|
||||
existingEntity.total_salary_limit_rounded = model.total_salary_limit_rounded;
|
||||
existingEntity.remark = model.remark;
|
||||
|
||||
existingEntity.SetAutoField(_repository.Context);
|
||||
foreach (var y in from z in _repository.Context.eva_limit_frame_employee where z.frame_group_guid == model.id orderby z.order_of_data select z)
|
||||
{
|
||||
int j = 1;
|
||||
if (y.help_org_id.HasValue)
|
||||
{
|
||||
var theemp = (from q in all_all_emp where q.id == y.employee_id select q).FirstOrDefault();
|
||||
var thedetail = (from r in working_record where r.employee_id == y.employee_id select r).FirstOrDefault();
|
||||
var help_at = (from s in mapping_dept where s.id == thedetail.place select s).FirstOrDefault();
|
||||
if (theemp != null && thedetail != null && help_at != null)
|
||||
{
|
||||
if (model.remark != "") existingEntity.remark += "\n";
|
||||
existingEntity.remark += $"{j}.ในลำดับที่ {y.order_of_data} {theemp.fullname} ตำแหน่ง{theemp.position_name} {theemp.department_name} \nมาช่วยปฏิบัติงานที่{help_at.department_name} ตั้งแต่วันที่ {MyHelper.GetDateStringForReport(thedetail.start_date)} - {MyHelper.GetDateStringForReport(thedetail.end_date)} \nตาม{thedetail.subject}";
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
existingEntity.SetAutoField(_repository.Context);
|
||||
|
||||
if (is_force_save)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user