82 lines
3.2 KiB
C#
82 lines
3.2 KiB
C#
using AutoMapper;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using TTSW.EF;
|
|
using TTSW.Utils;
|
|
using TTSW.Constant;
|
|
using TTSW.Common;
|
|
using TodoAPI2.Models;
|
|
using System.IO;
|
|
using System.Web;
|
|
using System.Net;
|
|
using TTSW.Configure;
|
|
using Microsoft.Extensions.Options;
|
|
using System.Data;
|
|
|
|
namespace TodoAPI2.Models
|
|
{
|
|
public class rep_summary_a01Service : Irep_summary_a01Service
|
|
{
|
|
private IBaseRepository<eva_level_scoreEntity, Guid> _repository;
|
|
private IMyDatabase db;
|
|
private Iexternal_linkageService ext;
|
|
private Iexternal_employeeService emp;
|
|
|
|
public rep_summary_a01Service(IBaseRepository<eva_level_scoreEntity, Guid> repository, IMyDatabase mydb, Iexternal_linkageService inext, Iexternal_employeeService inemp)
|
|
{
|
|
_repository = repository;
|
|
db = mydb;
|
|
ext = inext;
|
|
emp = inemp;
|
|
}
|
|
|
|
public rep_summary_a01WithSelectionViewModel GetWithSelection(Guid id)
|
|
{
|
|
var entity = _repository.Get(id);
|
|
var i = Mapper.Map<rep_summary_a01WithSelectionViewModel>(entity);
|
|
i.item_org_id = (from x in ext.GetSortingDep() select x).ToList();
|
|
i.item_round_id = (from x in ext.GetEvaRound() orderby x.external_code descending select x).ToList();
|
|
i.item_employee_id = (from x in emp.GetListByemployee_type(null, null) orderby x.fullname select x).ToList();
|
|
|
|
return i;
|
|
}
|
|
public rep_summary_a01WithSelectionViewModel GetBlankItem()
|
|
{
|
|
var i = new rep_summary_a01WithSelectionViewModel();
|
|
i.item_org_id = (from x in ext.GetSortingDep() select x).ToList();
|
|
i.item_round_id = (from x in ext.GetEvaRound() orderby x.external_code descending select x).ToList();
|
|
i.item_employee_id = (from x in emp.GetListByemployee_type(null, null) orderby x.fullname select x).ToList();
|
|
|
|
return i;
|
|
}
|
|
|
|
public string GetDisplayText(int? round_id)
|
|
{
|
|
var postponement = (from i in _repository.Context.eva_adjust_postponement
|
|
where i.id == round_id
|
|
select i).FirstOrDefault();
|
|
if(postponement != null)
|
|
{
|
|
var plan = (from i in _repository.Context.eva_performance_plan
|
|
where i.fiscal_year == postponement.fiscal_year
|
|
&& i.theTime == postponement.theRound
|
|
select i).FirstOrDefault();
|
|
if(plan != null)
|
|
{
|
|
var start = (from i in _repository.Context.eva_performance_plan_detail
|
|
where i.performance_plan_id == plan.id
|
|
select i.start_date).Min();
|
|
var end = (from i in _repository.Context.eva_performance_plan_detail
|
|
where i.performance_plan_id == plan.id
|
|
select i.end_date).Max();
|
|
return $"รอบที่ {postponement.theRound} ปี {postponement.fiscal_year} ({MyHelper.GetDateStringForReport(start)} - {MyHelper.GetDateStringForReport(end)})";
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|