เพิ่มประวัติ การดำเนินกิจกรรมการประเมิน
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
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;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public interface Ieva_create_evaluation_detail_historyService : IBaseService2<int, eva_create_evaluation_detail_historyInputModel, eva_create_evaluation_detail_historyViewModel>
|
||||
{
|
||||
new eva_create_evaluation_detail_historyViewModel Insert(eva_create_evaluation_detail_historyInputModel model, bool is_force_save);
|
||||
new eva_create_evaluation_detail_historyViewModel Update(int id, eva_create_evaluation_detail_historyInputModel model, bool is_force_save);
|
||||
List<eva_create_evaluation_detail_historyViewModel> GetListByevaluation_detail_id(int? evaluation_detail_id);
|
||||
List<eva_create_evaluation_detail_historyViewModel> GetListBySearch(eva_create_evaluation_detail_historySearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_create_evaluation_detail_historyInputModel> model, bool is_force_save);
|
||||
eva_create_evaluation_detail_historyWithSelectionViewModel GetWithSelection(int id);
|
||||
eva_create_evaluation_detail_historyWithSelectionViewModel GetBlankItem();
|
||||
|
||||
void RefreshAutoFieldOfAllData();
|
||||
eva_create_evaluation_detail_historyEntity GetEntity(int id);
|
||||
DataContext GetContext();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TTSW.EF;
|
||||
using TTSW.Utils;
|
||||
using TTSW.Constant;
|
||||
using TTSW.Common;
|
||||
using System.IO;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_create_evaluation_detail_historyEntity : BaseEntity2<int>
|
||||
{
|
||||
|
||||
|
||||
[ForeignKey("evaluation_detail_id")]
|
||||
public eva_create_evaluation_detailEntity eva_create_evaluation_detail_evaluation_detail_id { get; set; }
|
||||
public int? evaluation_detail_id { get; set; }
|
||||
|
||||
public DateTime? action_dt { get; set; }
|
||||
|
||||
[MaxLength(4000)]
|
||||
public string action_detail { get; set; }
|
||||
|
||||
public int? action_emp_id { get; set; }
|
||||
|
||||
|
||||
public void SetAutoField(DataContext context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void DoAfterInsertUpdate(DataContext context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TTSW.EF;
|
||||
using TTSW.Utils;
|
||||
using TTSW.Constant;
|
||||
using TTSW.Common;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_create_evaluation_detail_historyInputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? evaluation_detail_id { get; set; }
|
||||
|
||||
public DateTime? action_dt { get; set; }
|
||||
|
||||
public string action_detail { get; set; }
|
||||
|
||||
public int? action_emp_id { get; set; }
|
||||
|
||||
public string active_mode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TTSW.EF;
|
||||
using TTSW.Utils;
|
||||
using TTSW.Constant;
|
||||
using TTSW.Common;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_create_evaluation_detail_historyReportRequestModel : eva_create_evaluation_detail_historySearchModel
|
||||
{
|
||||
public string filetype { get; set; }
|
||||
|
||||
public string contentType { get { return MyHelper.GetContentType(filetype); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TTSW.EF;
|
||||
using TTSW.Utils;
|
||||
using TTSW.Constant;
|
||||
using TTSW.Common;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_create_evaluation_detail_historySearchModel
|
||||
{
|
||||
|
||||
public int id { get; set; }
|
||||
|
||||
public int? evaluation_detail_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,310 @@
|
||||
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 eva_create_evaluation_detail_historyService : Ieva_create_evaluation_detail_historyService
|
||||
{
|
||||
private IBaseRepository2<eva_create_evaluation_detail_historyEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
|
||||
public eva_create_evaluation_detail_historyService(IBaseRepository2<eva_create_evaluation_detail_historyEntity, int> repository, IMyDatabase mydb,
|
||||
Iexternal_linkageService inext, Iexternal_employeeService inemp)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
emp = inemp;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_create_evaluation_detail_historyEntity GetEntity(eva_create_evaluation_detail_historyInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detail_historyEntity>(model);
|
||||
}
|
||||
private List<eva_create_evaluation_detail_historyEntity> GetEntityList(List<eva_create_evaluation_detail_historyInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detail_historyEntity>>(models);
|
||||
}
|
||||
private eva_create_evaluation_detail_historyViewModel GetDto(eva_create_evaluation_detail_historyEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detail_historyViewModel>(entity);
|
||||
}
|
||||
private List<eva_create_evaluation_detail_historyViewModel> GetDtoList(List<eva_create_evaluation_detail_historyEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detail_historyViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_create_evaluation_detail_historyViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detail_historyEntity GetEntity(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public DataContext GetContext()
|
||||
{
|
||||
return _repository.Context;
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detail_historyWithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_create_evaluation_detail_historyWithSelectionViewModel>(entity);
|
||||
i.item_action_emp_id = emp.GetAllEmployee();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_create_evaluation_detail_historyWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_create_evaluation_detail_historyWithSelectionViewModel();
|
||||
i.item_action_emp_id = emp.GetAllEmployee();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_historyViewModel> GetListByevaluation_detail_id(int? evaluation_detail_id)
|
||||
{
|
||||
var model = new eva_create_evaluation_detail_historySearchModel();
|
||||
model.evaluation_detail_id = evaluation_detail_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_historyViewModel> GetListBySearch(eva_create_evaluation_detail_historySearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_create_evaluation_detail_history in _repository.Context.eva_create_evaluation_detail_history
|
||||
|
||||
join fk_eva_create_evaluation_detail1 in _repository.Context.eva_create_evaluation_detail on m_eva_create_evaluation_detail_history.evaluation_detail_id equals fk_eva_create_evaluation_detail1.id
|
||||
into eva_create_evaluation_detailResult1
|
||||
from fk_eva_create_evaluation_detailResult1 in eva_create_evaluation_detailResult1.DefaultIfEmpty()
|
||||
|
||||
join fk_external_employee4 in emp.GetAllEmployee() on m_eva_create_evaluation_detail_history.action_emp_id equals fk_external_employee4.id
|
||||
into external_employeeResult4
|
||||
from fk_external_employeeResult4 in external_employeeResult4.DefaultIfEmpty()
|
||||
|
||||
where
|
||||
1 == 1
|
||||
&& (!model.evaluation_detail_id.HasValue || m_eva_create_evaluation_detail_history.evaluation_detail_id == model.evaluation_detail_id)
|
||||
|
||||
orderby m_eva_create_evaluation_detail_history.action_dt
|
||||
select new eva_create_evaluation_detail_historyViewModel()
|
||||
{
|
||||
id = m_eva_create_evaluation_detail_history.id,
|
||||
evaluation_detail_id = m_eva_create_evaluation_detail_history.evaluation_detail_id,
|
||||
action_dt = m_eva_create_evaluation_detail_history.action_dt,
|
||||
action_detail = m_eva_create_evaluation_detail_history.action_detail,
|
||||
action_emp_id = m_eva_create_evaluation_detail_history.action_emp_id,
|
||||
|
||||
evaluation_detail_id_eva_create_evaluation_detail_create_evaluation_id = fk_eva_create_evaluation_detailResult1.create_evaluation_id,
|
||||
action_emp_id_external_employee_fullname = fk_external_employeeResult4.fullname,
|
||||
|
||||
isActive = m_eva_create_evaluation_detail_history.isActive,
|
||||
Created = m_eva_create_evaluation_detail_history.created,
|
||||
Updated = m_eva_create_evaluation_detail_history.updated
|
||||
}
|
||||
).Take(1000).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
|
||||
public int GetNewPrimaryKey()
|
||||
{
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_create_evaluation_detail_history
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if(x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
|
||||
return newkey.Value;
|
||||
}
|
||||
|
||||
|
||||
public eva_create_evaluation_detail_historyViewModel Insert(eva_create_evaluation_detail_historyInputModel model, bool is_force_save)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
entity.SetAutoField(_repository.Context);
|
||||
|
||||
if (is_force_save)
|
||||
{
|
||||
var inserted = _repository.Insert(entity);
|
||||
entity.DoAfterInsertUpdate(_repository.Context);
|
||||
return Get(inserted.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
_repository.InsertWithoutCommit(entity);
|
||||
entity.DoAfterInsertUpdate(_repository.Context);
|
||||
return Mapper.Map<eva_create_evaluation_detail_historyViewModel>(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detail_historyViewModel Update(int id, eva_create_evaluation_detail_historyInputModel model, bool is_force_save)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.evaluation_detail_id = model.evaluation_detail_id;
|
||||
existingEntity.action_dt = model.action_dt;
|
||||
existingEntity.action_detail = model.action_detail;
|
||||
existingEntity.action_emp_id = model.action_emp_id;
|
||||
|
||||
existingEntity.SetAutoField(_repository.Context);
|
||||
|
||||
if (is_force_save)
|
||||
{
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
existingEntity.DoAfterInsertUpdate(_repository.Context);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
_repository.UpdateWithoutCommit(id, existingEntity);
|
||||
existingEntity.DoAfterInsertUpdate(_repository.Context);
|
||||
return Mapper.Map<eva_create_evaluation_detail_historyViewModel>(existingEntity);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_create_evaluation_detail_historyInputModel> model, bool is_force_save)
|
||||
{
|
||||
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.evaluation_detail_id = i.evaluation_detail_id;
|
||||
existingEntity.action_dt = i.action_dt;
|
||||
existingEntity.action_detail = i.action_detail;
|
||||
existingEntity.action_emp_id = i.action_emp_id;
|
||||
|
||||
existingEntity.SetAutoField(_repository.Context);
|
||||
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
|
||||
}
|
||||
}
|
||||
else if (i.active_mode == "1" && !i.id.HasValue) // add
|
||||
{
|
||||
var entity = GetEntity(i);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
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();
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detail_historyViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_create_evaluation_detail_historyViewModel SetAsInactive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsInActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public void Delete(int id)
|
||||
{
|
||||
_repository.Delete(id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void RefreshAutoFieldOfAllData()
|
||||
{
|
||||
var all_items = from i in _repository.Context.eva_create_evaluation_detail_history
|
||||
select i;
|
||||
foreach (var item in all_items)
|
||||
{
|
||||
item.SetAutoField(_repository.Context);
|
||||
}
|
||||
_repository.Context.SaveChanges();
|
||||
}
|
||||
|
||||
private Dictionary<string,string> GetLookupForLog()
|
||||
{
|
||||
var i = new Dictionary<string, string>();
|
||||
|
||||
|
||||
i.Add("evaluation_detail_id", "การประเมิน");
|
||||
i.Add("evaluation_detail_id_eva_create_evaluation_detail_create_evaluation_id", "การประเมิน");
|
||||
i.Add("action_dt", "วันที่/เวลา");
|
||||
i.Add("txt_action_dt", "วันที่/เวลา");
|
||||
i.Add("action_detail", "รายละเอียด");
|
||||
i.Add("action_emp_id", "ผู้ดำเนินการ");
|
||||
i.Add("action_emp_id_external_employee_employee_type", "ผู้ดำเนินการ");
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Match Item
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TTSW.EF;
|
||||
using TTSW.Utils;
|
||||
using TTSW.Constant;
|
||||
using TTSW.Common;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_create_evaluation_detail_historyViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? evaluation_detail_id { get; set; }
|
||||
|
||||
public DateTime? action_dt { get; set; }
|
||||
|
||||
public string txt_action_dt { get { return MyHelper.GetDateStringForReport(this.action_dt); } }
|
||||
|
||||
public string action_detail { get; set; }
|
||||
|
||||
public int? action_emp_id { get; set; }
|
||||
|
||||
public int? evaluation_detail_id_eva_create_evaluation_detail_create_evaluation_id { get; set; }
|
||||
public string action_emp_id_external_employee_fullname { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_create_evaluation_detail_historyWithSelectionViewModel: eva_create_evaluation_detail_historyViewModel
|
||||
{
|
||||
public List<external_employeeViewModel> item_action_emp_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user