รวม code ส่งเข้า ZD
This commit is contained in:
@@ -14,6 +14,8 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_create_evaluationEntity : BaseEntity2<int>
|
||||
{
|
||||
|
||||
|
||||
[ForeignKey("performance_plan_id")]
|
||||
public eva_performance_planEntity eva_performance_plan { get; set; }
|
||||
public Guid? performance_plan_id { get; set; }
|
||||
@@ -27,7 +29,11 @@ namespace TodoAPI2.Models
|
||||
[ForeignKey("evaluation_group_id")]
|
||||
public eva_evaluation_groupEntity eva_evaluation_group { get; set; }
|
||||
public Guid? evaluation_group_id { get; set; }
|
||||
|
||||
public int? supervisor1_id { get; set; }
|
||||
|
||||
public int? supervisor2_id { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,10 @@ namespace TodoAPI2.Models
|
||||
|
||||
public Guid? evaluation_group_id { get; set; }
|
||||
|
||||
public int? supervisor1_id { get; set; }
|
||||
|
||||
public int? supervisor2_id { get; set; }
|
||||
|
||||
public string active_mode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,22 +64,28 @@ namespace TodoAPI2.Models
|
||||
}
|
||||
public eva_create_evaluationWithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_create_evaluationWithSelectionViewModel>(entity);
|
||||
i.item_performance_plan_id = (from x in _repository.Context.eva_performance_plan select x).ToList();
|
||||
i.item_employee_id = emp.GetListByemployee_type(null, null);
|
||||
i.item_employee_id = all_emp;
|
||||
i.item_evaluation_group_id = (from x in _repository.Context.eva_evaluation_group select x).ToList();
|
||||
|
||||
i.item_supervisor1_id = all_emp;
|
||||
i.item_supervisor2_id = all_emp;
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_create_evaluationWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
var i = new eva_create_evaluationWithSelectionViewModel();
|
||||
i.item_performance_plan_id = (from x in _repository.Context.eva_performance_plan select x).ToList();
|
||||
i.item_employee_id = emp.GetListByemployee_type(null, null);
|
||||
i.item_employee_id = all_emp;
|
||||
i.item_evaluation_group_id = (from x in _repository.Context.eva_evaluation_group select x).ToList();
|
||||
|
||||
i.item_supervisor1_id = all_emp;
|
||||
i.item_supervisor2_id = all_emp;
|
||||
|
||||
return i;
|
||||
}
|
||||
@@ -93,6 +99,8 @@ namespace TodoAPI2.Models
|
||||
|
||||
public List<eva_create_evaluationViewModel> GetListBySearch(eva_create_evaluationSearchModel model)
|
||||
{
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
var data = (
|
||||
from m_eva_create_evaluation in _repository.Context.eva_create_evaluation
|
||||
|
||||
@@ -100,7 +108,7 @@ namespace TodoAPI2.Models
|
||||
into eva_performance_planResult1
|
||||
from fk_eva_performance_planResult1 in eva_performance_planResult1.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage2 in emp.GetListByemployee_type(null,null) on m_eva_create_evaluation.employee_id equals fk_external_linkage2.id
|
||||
join fk_external_linkage2 in all_emp on m_eva_create_evaluation.employee_id equals fk_external_linkage2.id
|
||||
into external_linkageResult2
|
||||
from fk_external_linkageResult2 in external_linkageResult2.DefaultIfEmpty()
|
||||
|
||||
@@ -108,8 +116,15 @@ namespace TodoAPI2.Models
|
||||
into eva_evaluation_groupResult5
|
||||
from fk_eva_evaluation_groupResult5 in eva_evaluation_groupResult5.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage6 in all_emp on m_eva_create_evaluation.supervisor1_id equals fk_external_linkage6.id
|
||||
into external_linkageResult6
|
||||
from fk_external_linkageResult6 in external_linkageResult6.DefaultIfEmpty()
|
||||
|
||||
where 1==1
|
||||
join fk_external_linkage7 in all_emp on m_eva_create_evaluation.supervisor2_id equals fk_external_linkage7.id
|
||||
into external_linkageResult7
|
||||
from fk_external_linkageResult7 in external_linkageResult7.DefaultIfEmpty()
|
||||
|
||||
where 1==1
|
||||
&& (m_eva_create_evaluation.performance_plan_id == model.performance_plan_id || !model.performance_plan_id.HasValue)
|
||||
&& (m_eva_create_evaluation.evaluation_group_id == model.evaluation_group_id || !model.evaluation_group_id.HasValue)
|
||||
|
||||
@@ -123,10 +138,14 @@ namespace TodoAPI2.Models
|
||||
score1 = m_eva_create_evaluation.score1,
|
||||
score2 = m_eva_create_evaluation.score2,
|
||||
evaluation_group_id = m_eva_create_evaluation.evaluation_group_id,
|
||||
supervisor1_id = m_eva_create_evaluation.supervisor1_id,
|
||||
supervisor2_id = m_eva_create_evaluation.supervisor2_id,
|
||||
|
||||
performance_plan_id_eva_performance_plan_fiscal_year = fk_eva_performance_planResult1.fiscal_year,
|
||||
employee_id_external_linkage_external_name = fk_external_linkageResult2.fullname,
|
||||
evaluation_group_id_eva_evaluation_group_code = fk_eva_evaluation_groupResult5.thegroup,
|
||||
evaluation_group_id_eva_evaluation_group_code = fk_eva_evaluation_groupResult5.code,
|
||||
supervisor1_id_external_linkage_external_name = fk_external_linkageResult6.fullname,
|
||||
supervisor2_id_external_linkage_external_name = fk_external_linkageResult7.fullname,
|
||||
|
||||
isActive = m_eva_create_evaluation.isActive,
|
||||
Created = m_eva_create_evaluation.created,
|
||||
@@ -180,6 +199,8 @@ namespace TodoAPI2.Models
|
||||
existingEntity.score1 = model.score1;
|
||||
existingEntity.score2 = model.score2;
|
||||
existingEntity.evaluation_group_id = model.evaluation_group_id;
|
||||
existingEntity.supervisor1_id = model.supervisor1_id;
|
||||
existingEntity.supervisor2_id = model.supervisor2_id;
|
||||
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
@@ -198,11 +219,13 @@ namespace TodoAPI2.Models
|
||||
var existingEntity = _repository.Get(i.id.Value);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.performance_plan_id = i.performance_plan_id;
|
||||
existingEntity.employee_id = i.employee_id;
|
||||
existingEntity.score1 = i.score1;
|
||||
existingEntity.score2 = i.score2;
|
||||
existingEntity.evaluation_group_id = i.evaluation_group_id;
|
||||
existingEntity.performance_plan_id = i.performance_plan_id;
|
||||
existingEntity.employee_id = i.employee_id;
|
||||
existingEntity.score1 = i.score1;
|
||||
existingEntity.score2 = i.score2;
|
||||
existingEntity.evaluation_group_id = i.evaluation_group_id;
|
||||
existingEntity.supervisor1_id = i.supervisor1_id;
|
||||
existingEntity.supervisor2_id = i.supervisor2_id;
|
||||
|
||||
|
||||
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
|
||||
|
||||
@@ -24,9 +24,15 @@ namespace TodoAPI2.Models
|
||||
|
||||
public Guid? evaluation_group_id { get; set; }
|
||||
|
||||
public int? supervisor1_id { get; set; }
|
||||
|
||||
public int? supervisor2_id { get; set; }
|
||||
|
||||
public int? performance_plan_id_eva_performance_plan_fiscal_year { get; set; }
|
||||
public string employee_id_external_linkage_external_name { get; set; }
|
||||
public string evaluation_group_id_eva_evaluation_group_code { get; set; }
|
||||
public string supervisor1_id_external_linkage_external_name { get; set; }
|
||||
public string supervisor2_id_external_linkage_external_name { get; set; }
|
||||
|
||||
public string description
|
||||
{
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace TodoAPI2.Models
|
||||
public List<eva_performance_planEntity> item_performance_plan_id { get; set; }
|
||||
public List<external_employeeViewModel> item_employee_id { get; set; }
|
||||
public List<eva_evaluation_groupEntity> item_evaluation_group_id { get; set; }
|
||||
public List<external_employeeViewModel> item_supervisor1_id { get; set; }
|
||||
public List<external_employeeViewModel> item_supervisor2_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,24 @@ namespace TodoAPI2.Models
|
||||
[MaxLength(1)]
|
||||
public string status_supervisor { get; set; }
|
||||
|
||||
public int? supervisor1A { get; set; }
|
||||
|
||||
[MaxLength(1)]
|
||||
public string supervisor1A_result { get; set; }
|
||||
|
||||
[MaxLength(1000)]
|
||||
public string supervisor1A_remark { get; set; }
|
||||
|
||||
public DateTime? supervisor1A_date { get; set; }
|
||||
|
||||
public int? supervisor2A { get; set; }
|
||||
|
||||
[MaxLength(1)]
|
||||
public string supervisor2A_result { get; set; }
|
||||
|
||||
[MaxLength(1000)]
|
||||
public string supervisor2A_remark { get; set; }
|
||||
|
||||
public DateTime? supervisor2A_date { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
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_review03Service : IBaseService<int, eva_create_evaluation_detail_review03InputModel, eva_create_evaluation_detail_review03ViewModel>
|
||||
{
|
||||
new eva_create_evaluation_detail_review03ViewModel Insert(eva_create_evaluation_detail_review03InputModel model);
|
||||
new eva_create_evaluation_detail_review03ViewModel Update(int id, eva_create_evaluation_detail_review03InputModel model);
|
||||
List<eva_create_evaluation_detail_review03ViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id);
|
||||
List<eva_create_evaluation_detail_review03ViewModel> GetListBySearch(eva_create_evaluation_detail_review03SearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_create_evaluation_detail_review03InputModel> model);
|
||||
eva_create_evaluation_detail_review03WithSelectionViewModel GetWithSelection(int id);
|
||||
eva_create_evaluation_detail_review03WithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
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_review03InputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? supervisor1A { get; set; }
|
||||
|
||||
public string supervisor1A_result { get; set; }
|
||||
|
||||
public string supervisor1A_remark { get; set; }
|
||||
|
||||
public DateTime? supervisor1A_date { 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_review03ReportRequestModel : eva_create_evaluation_detail_review03SearchModel
|
||||
{
|
||||
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_review03SearchModel
|
||||
{
|
||||
|
||||
public int id { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,239 @@
|
||||
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_review03Service : Ieva_create_evaluation_detail_review03Service
|
||||
{
|
||||
private IBaseRepository2<eva_create_evaluation_detailEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
|
||||
public eva_create_evaluation_detail_review03Service(IBaseRepository2<eva_create_evaluation_detailEntity, int> repository, IMyDatabase mydb, Iexternal_linkageService inext)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_create_evaluation_detailEntity GetEntity(eva_create_evaluation_detail_review03InputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detailEntity>(model);
|
||||
}
|
||||
private List<eva_create_evaluation_detailEntity> GetEntityList(List<eva_create_evaluation_detail_review03InputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detailEntity>>(models);
|
||||
}
|
||||
private eva_create_evaluation_detail_review03ViewModel GetDto(eva_create_evaluation_detailEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detail_review03ViewModel>(entity);
|
||||
}
|
||||
private List<eva_create_evaluation_detail_review03ViewModel> GetDtoList(List<eva_create_evaluation_detailEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detail_review03ViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_create_evaluation_detail_review03ViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_create_evaluation_detail_review03WithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_create_evaluation_detail_review03WithSelectionViewModel>(entity);
|
||||
i.item_supervisor1A_result = (from x in ext.GetAgreeDisagree() select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_create_evaluation_detail_review03WithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_create_evaluation_detail_review03WithSelectionViewModel();
|
||||
i.item_supervisor1A_result = (from x in ext.GetAgreeDisagree() select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_review03ViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id)
|
||||
{
|
||||
var model = new eva_create_evaluation_detail_review03SearchModel();
|
||||
model.create_evaluation_id = create_evaluation_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_review03ViewModel> GetListBySearch(eva_create_evaluation_detail_review03SearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_create_evaluation_detail_review03 in _repository.Context.eva_create_evaluation_detail
|
||||
|
||||
join fk_external_linkage3 in ext.GetAgreeDisagree() on m_eva_create_evaluation_detail_review03.supervisor1A_result equals fk_external_linkage3.external_code
|
||||
into external_linkageResult3
|
||||
from fk_external_linkageResult3 in external_linkageResult3.DefaultIfEmpty()
|
||||
|
||||
|
||||
where 1==1
|
||||
//&& (m_eva_create_evaluation_detail_review03.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_create_evaluation_detail_review03.create_evaluation_id == model.create_evaluation_id || !model.create_evaluation_id.HasValue)
|
||||
|
||||
|
||||
orderby m_eva_create_evaluation_detail_review03.created descending
|
||||
select new eva_create_evaluation_detail_review03ViewModel()
|
||||
{
|
||||
id = m_eva_create_evaluation_detail_review03.id,
|
||||
create_evaluation_id = m_eva_create_evaluation_detail_review03.create_evaluation_id,
|
||||
supervisor1A = m_eva_create_evaluation_detail_review03.supervisor1A,
|
||||
supervisor1A_result = m_eva_create_evaluation_detail_review03.supervisor1A_result,
|
||||
supervisor1A_remark = m_eva_create_evaluation_detail_review03.supervisor1A_remark,
|
||||
supervisor1A_date = m_eva_create_evaluation_detail_review03.supervisor1A_date,
|
||||
|
||||
supervisor1A_result_external_linkage_external_name = fk_external_linkageResult3.external_name,
|
||||
|
||||
isActive = m_eva_create_evaluation_detail_review03.isActive,
|
||||
Created = m_eva_create_evaluation_detail_review03.created,
|
||||
Updated = m_eva_create_evaluation_detail_review03.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
public int GetNewPrimaryKey()
|
||||
{
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_create_evaluation_detail
|
||||
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_review03ViewModel Insert(eva_create_evaluation_detail_review03InputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detail_review03ViewModel Update(int id, eva_create_evaluation_detail_review03InputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.create_evaluation_id = model.create_evaluation_id;
|
||||
existingEntity.supervisor1A = model.supervisor1A;
|
||||
existingEntity.supervisor1A_result = model.supervisor1A_result;
|
||||
existingEntity.supervisor1A_remark = model.supervisor1A_remark;
|
||||
existingEntity.supervisor1A_date = model.supervisor1A_date;
|
||||
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_create_evaluation_detail_review03InputModel> 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.create_evaluation_id = i.create_evaluation_id;
|
||||
existingEntity.supervisor1A = i.supervisor1A;
|
||||
existingEntity.supervisor1A_result = i.supervisor1A_result;
|
||||
existingEntity.supervisor1A_remark = i.supervisor1A_remark;
|
||||
existingEntity.supervisor1A_date = i.supervisor1A_date;
|
||||
|
||||
|
||||
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
|
||||
}
|
||||
}
|
||||
else if (i.active_mode == "1" && !i.id.HasValue) // add
|
||||
{
|
||||
var entity = GetEntity(i);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
_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();
|
||||
|
||||
return model.Count().ToString();
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detail_review03ViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_create_evaluation_detail_review03ViewModel SetAsInactive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsInActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public void Delete(int id)
|
||||
{
|
||||
_repository.Delete(id);
|
||||
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Match Item
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
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_review03ViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? supervisor1A { get; set; }
|
||||
|
||||
public string supervisor1A_result { get; set; }
|
||||
|
||||
public string supervisor1A_remark { get; set; }
|
||||
|
||||
public DateTime? supervisor1A_date { get; set; }
|
||||
|
||||
public string txt_supervisor1A_date { get { return MyHelper.GetDateStringForReport(this.supervisor1A_date); } }
|
||||
|
||||
public string supervisor1A_result_external_linkage_external_name { 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_review03WithSelectionViewModel: eva_create_evaluation_detail_review03ViewModel
|
||||
{
|
||||
public List<external_linkageViewModel> item_supervisor1A_result { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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_review04Service : IBaseService<int, eva_create_evaluation_detail_review04InputModel, eva_create_evaluation_detail_review04ViewModel>
|
||||
{
|
||||
new eva_create_evaluation_detail_review04ViewModel Insert(eva_create_evaluation_detail_review04InputModel model);
|
||||
new eva_create_evaluation_detail_review04ViewModel Update(int id, eva_create_evaluation_detail_review04InputModel model);
|
||||
List<eva_create_evaluation_detail_review04ViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id);
|
||||
List<eva_create_evaluation_detail_review04ViewModel> GetListBySearch(eva_create_evaluation_detail_review04SearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_create_evaluation_detail_review04InputModel> model);
|
||||
eva_create_evaluation_detail_review04WithSelectionViewModel GetWithSelection(int id);
|
||||
eva_create_evaluation_detail_review04WithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
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_review04InputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? supervisor2A { get; set; }
|
||||
|
||||
public string supervisor2A_result { get; set; }
|
||||
|
||||
public string supervisor2A_remark { get; set; }
|
||||
|
||||
public DateTime? supervisor2A_date { 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_review04ReportRequestModel : eva_create_evaluation_detail_review04SearchModel
|
||||
{
|
||||
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_review04SearchModel
|
||||
{
|
||||
|
||||
public int id { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,239 @@
|
||||
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_review04Service : Ieva_create_evaluation_detail_review04Service
|
||||
{
|
||||
private IBaseRepository2<eva_create_evaluation_detailEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
|
||||
public eva_create_evaluation_detail_review04Service(IBaseRepository2<eva_create_evaluation_detailEntity, int> repository, IMyDatabase mydb, Iexternal_linkageService inext)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_create_evaluation_detailEntity GetEntity(eva_create_evaluation_detail_review04InputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detailEntity>(model);
|
||||
}
|
||||
private List<eva_create_evaluation_detailEntity> GetEntityList(List<eva_create_evaluation_detail_review04InputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detailEntity>>(models);
|
||||
}
|
||||
private eva_create_evaluation_detail_review04ViewModel GetDto(eva_create_evaluation_detailEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detail_review04ViewModel>(entity);
|
||||
}
|
||||
private List<eva_create_evaluation_detail_review04ViewModel> GetDtoList(List<eva_create_evaluation_detailEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detail_review04ViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_create_evaluation_detail_review04ViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_create_evaluation_detail_review04WithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_create_evaluation_detail_review04WithSelectionViewModel>(entity);
|
||||
i.item_supervisor2A_result = (from x in ext.GetAgreeDisagree() select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_create_evaluation_detail_review04WithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_create_evaluation_detail_review04WithSelectionViewModel();
|
||||
i.item_supervisor2A_result = (from x in ext.GetAgreeDisagree() select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_review04ViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id)
|
||||
{
|
||||
var model = new eva_create_evaluation_detail_review04SearchModel();
|
||||
model.create_evaluation_id = create_evaluation_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_review04ViewModel> GetListBySearch(eva_create_evaluation_detail_review04SearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_create_evaluation_detail_review04 in _repository.Context.eva_create_evaluation_detail
|
||||
|
||||
join fk_external_linkage3 in ext.GetAgreeDisagree() on m_eva_create_evaluation_detail_review04.supervisor2A_result equals fk_external_linkage3.external_code
|
||||
into external_linkageResult3
|
||||
from fk_external_linkageResult3 in external_linkageResult3.DefaultIfEmpty()
|
||||
|
||||
|
||||
where 1==1
|
||||
//&& (m_eva_create_evaluation_detail_review04.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_create_evaluation_detail_review04.create_evaluation_id == model.create_evaluation_id || !model.create_evaluation_id.HasValue)
|
||||
|
||||
|
||||
orderby m_eva_create_evaluation_detail_review04.created descending
|
||||
select new eva_create_evaluation_detail_review04ViewModel()
|
||||
{
|
||||
id = m_eva_create_evaluation_detail_review04.id,
|
||||
create_evaluation_id = m_eva_create_evaluation_detail_review04.create_evaluation_id,
|
||||
supervisor2A = m_eva_create_evaluation_detail_review04.supervisor2A,
|
||||
supervisor2A_result = m_eva_create_evaluation_detail_review04.supervisor2A_result,
|
||||
supervisor2A_remark = m_eva_create_evaluation_detail_review04.supervisor2A_remark,
|
||||
supervisor2A_date = m_eva_create_evaluation_detail_review04.supervisor2A_date,
|
||||
|
||||
supervisor2A_result_external_linkage_external_name = fk_external_linkageResult3.external_name,
|
||||
|
||||
isActive = m_eva_create_evaluation_detail_review04.isActive,
|
||||
Created = m_eva_create_evaluation_detail_review04.created,
|
||||
Updated = m_eva_create_evaluation_detail_review04.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
public int GetNewPrimaryKey()
|
||||
{
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_create_evaluation_detail
|
||||
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_review04ViewModel Insert(eva_create_evaluation_detail_review04InputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detail_review04ViewModel Update(int id, eva_create_evaluation_detail_review04InputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.create_evaluation_id = model.create_evaluation_id;
|
||||
existingEntity.supervisor2A = model.supervisor2A;
|
||||
existingEntity.supervisor2A_result = model.supervisor2A_result;
|
||||
existingEntity.supervisor2A_remark = model.supervisor2A_remark;
|
||||
existingEntity.supervisor2A_date = model.supervisor2A_date;
|
||||
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_create_evaluation_detail_review04InputModel> 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.create_evaluation_id = i.create_evaluation_id;
|
||||
existingEntity.supervisor2A = i.supervisor2A;
|
||||
existingEntity.supervisor2A_result = i.supervisor2A_result;
|
||||
existingEntity.supervisor2A_remark = i.supervisor2A_remark;
|
||||
existingEntity.supervisor2A_date = i.supervisor2A_date;
|
||||
|
||||
|
||||
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
|
||||
}
|
||||
}
|
||||
else if (i.active_mode == "1" && !i.id.HasValue) // add
|
||||
{
|
||||
var entity = GetEntity(i);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
_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();
|
||||
|
||||
return model.Count().ToString();
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detail_review04ViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_create_evaluation_detail_review04ViewModel SetAsInactive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsInActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public void Delete(int id)
|
||||
{
|
||||
_repository.Delete(id);
|
||||
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Match Item
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
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_review04ViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? supervisor2A { get; set; }
|
||||
|
||||
public string supervisor2A_result { get; set; }
|
||||
|
||||
public string supervisor2A_remark { get; set; }
|
||||
|
||||
public DateTime? supervisor2A_date { get; set; }
|
||||
|
||||
public string txt_supervisor2A_date { get { return MyHelper.GetDateStringForReport(this.supervisor2A_date); } }
|
||||
|
||||
public string supervisor2A_result_external_linkage_external_name { 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_review04WithSelectionViewModel: eva_create_evaluation_detail_review04ViewModel
|
||||
{
|
||||
public List<external_linkageViewModel> item_supervisor2A_result { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,16 @@ namespace TodoAPI2.Models
|
||||
|
||||
public string thefile { get; set; }
|
||||
|
||||
public string target_score1 { get; set; }
|
||||
|
||||
public string target_score2 { get; set; }
|
||||
|
||||
public string target_score3 { get; set; }
|
||||
|
||||
public string target_score4 { get; set; }
|
||||
|
||||
public string target_score5 { get; set; }
|
||||
|
||||
public string active_mode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,14 +20,14 @@ namespace TodoAPI2.Models
|
||||
public class eva_evaluation_achievementService : Ieva_evaluation_achievementService
|
||||
{
|
||||
private IBaseRepository2<eva_evaluation_achievementEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
|
||||
public eva_evaluation_achievementService(IBaseRepository2<eva_evaluation_achievementEntity, int> 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_evaluation_achievementViewModel>>(entities);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
@@ -77,12 +77,12 @@ namespace TodoAPI2.Models
|
||||
|
||||
public List<eva_evaluation_achievementViewModel> GetListBycreate_evaluation_detail_id(int? create_evaluation_detail_id)
|
||||
{
|
||||
var model = new eva_evaluation_achievementSearchModel();
|
||||
var model = new eva_evaluation_achievementSearchModel();
|
||||
model.create_evaluation_detail_id = create_evaluation_detail_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_evaluation_achievementViewModel> GetListBySearch(eva_evaluation_achievementSearchModel model)
|
||||
public List<eva_evaluation_achievementViewModel> GetListBySearch(eva_evaluation_achievementSearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_evaluation_achievement in _repository.Context.eva_evaluation_achievement
|
||||
@@ -92,11 +92,11 @@ namespace TodoAPI2.Models
|
||||
from fk_eva_create_evaluation_detailResult1 in eva_create_evaluation_detailResult1.DefaultIfEmpty()
|
||||
|
||||
|
||||
where 1==1
|
||||
where 1 == 1
|
||||
&& (m_eva_evaluation_achievement.create_evaluation_detail_id == model.create_evaluation_detail_id || !model.create_evaluation_detail_id.HasValue)
|
||||
|
||||
|
||||
orderby m_eva_evaluation_achievement.achievement
|
||||
orderby m_eva_evaluation_achievement.achievement
|
||||
select new eva_evaluation_achievementViewModel()
|
||||
{
|
||||
id = m_eva_evaluation_achievement.id,
|
||||
@@ -108,6 +108,12 @@ namespace TodoAPI2.Models
|
||||
|
||||
create_evaluation_detail_id_eva_create_evaluation_detail_create_evaluation_id = fk_eva_create_evaluation_detailResult1.create_evaluation_id,
|
||||
|
||||
target_score1 = m_eva_evaluation_achievement.target_score1,
|
||||
target_score2 = m_eva_evaluation_achievement.target_score2,
|
||||
target_score3 = m_eva_evaluation_achievement.target_score3,
|
||||
target_score4 = m_eva_evaluation_achievement.target_score4,
|
||||
target_score5 = m_eva_evaluation_achievement.target_score5,
|
||||
|
||||
isActive = m_eva_evaluation_achievement.isActive,
|
||||
Created = m_eva_evaluation_achievement.created,
|
||||
Updated = m_eva_evaluation_achievement.updated
|
||||
@@ -126,10 +132,10 @@ namespace TodoAPI2.Models
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_evaluation_achievement
|
||||
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;
|
||||
}
|
||||
@@ -143,6 +149,7 @@ namespace TodoAPI2.Models
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
var current_sum = (from i in _repository.Context.eva_evaluation_achievement
|
||||
where i.create_evaluation_detail_id == model.create_evaluation_detail_id
|
||||
select i.weight).Sum();
|
||||
|
||||
if (current_sum + model.weight > 100)
|
||||
@@ -159,17 +166,18 @@ namespace TodoAPI2.Models
|
||||
}
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_evaluation_achievementViewModel Update(int id, eva_evaluation_achievementInputModel model)
|
||||
{
|
||||
var current_sum = (from i in _repository.Context.eva_evaluation_achievement
|
||||
where i.create_evaluation_detail_id == model.create_evaluation_detail_id
|
||||
select i.weight).Sum();
|
||||
|
||||
var current_item_weight = (from i in _repository.Context.eva_evaluation_achievement
|
||||
where i.id==id
|
||||
where i.id == id
|
||||
select i.weight).Sum();
|
||||
|
||||
if (current_sum - current_item_weight + model.weight > 100)
|
||||
@@ -185,61 +193,69 @@ namespace TodoAPI2.Models
|
||||
existingEntity.weight = model.weight;
|
||||
if (!string.IsNullOrEmpty(model.thefile))
|
||||
{
|
||||
if (model.thefile.StartsWith("Uploads"))
|
||||
{
|
||||
var thefileFileName = FileUtil.MoveTempUploadFileToActualPath(
|
||||
if (model.thefile.StartsWith("Uploads"))
|
||||
{
|
||||
var thefileFileName = FileUtil.MoveTempUploadFileToActualPath(
|
||||
model.thefile, FilePathConstant.DirType.FilesTestUpload, existingEntity.id, existingEntity.thefile);
|
||||
existingEntity.thefile = thefileFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
existingEntity.thefile = model.thefile;
|
||||
}
|
||||
existingEntity.thefile = thefileFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
existingEntity.thefile = model.thefile;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
existingEntity.thefile = null;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
existingEntity.thefile = null;
|
||||
}
|
||||
existingEntity.target_score1 = model.target_score1;
|
||||
existingEntity.target_score2 = model.target_score2;
|
||||
existingEntity.target_score3 = model.target_score3;
|
||||
existingEntity.target_score4 = model.target_score4;
|
||||
existingEntity.target_score5 = model.target_score5;
|
||||
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_evaluation_achievementInputModel> model)
|
||||
public string UpdateMultiple(List<eva_evaluation_achievementInputModel> 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.create_evaluation_detail_id = i.create_evaluation_detail_id;
|
||||
existingEntity.achievement = i.achievement;
|
||||
existingEntity.weight = i.weight;
|
||||
if (!string.IsNullOrEmpty(i.thefile))
|
||||
{
|
||||
if (i.thefile.StartsWith("Uploads"))
|
||||
{
|
||||
var thefileFileName = FileUtil.MoveTempUploadFileToActualPath(
|
||||
i.thefile, FilePathConstant.DirType.FilesTestUpload, existingEntity.id, existingEntity.thefile);
|
||||
existingEntity.thefile = thefileFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
existingEntity.thefile = i.thefile;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
existingEntity.thefile = null;
|
||||
}
|
||||
|
||||
existingEntity.create_evaluation_detail_id = i.create_evaluation_detail_id;
|
||||
existingEntity.achievement = i.achievement;
|
||||
existingEntity.weight = i.weight;
|
||||
if (!string.IsNullOrEmpty(i.thefile))
|
||||
{
|
||||
if (i.thefile.StartsWith("Uploads"))
|
||||
{
|
||||
var thefileFileName = FileUtil.MoveTempUploadFileToActualPath(
|
||||
i.thefile, FilePathConstant.DirType.FilesTestUpload, existingEntity.id, existingEntity.thefile);
|
||||
existingEntity.thefile = thefileFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
existingEntity.thefile = i.thefile;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
existingEntity.thefile = null;
|
||||
}
|
||||
existingEntity.target_score1 = i.target_score1;
|
||||
existingEntity.target_score2 = i.target_score2;
|
||||
existingEntity.target_score3 = i.target_score3;
|
||||
existingEntity.target_score4 = i.target_score4;
|
||||
existingEntity.target_score5 = i.target_score5;
|
||||
|
||||
|
||||
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
|
||||
@@ -252,15 +268,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();
|
||||
}
|
||||
@@ -291,4 +307,6 @@ namespace TodoAPI2.Models
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,9 +30,19 @@ namespace TodoAPI2.Models
|
||||
return (string.IsNullOrEmpty(thefile) ? "" :
|
||||
$"<a href='../{thefileDisplay}' target='_blank'>{thefile}</a>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string target_score1 { get; set; }
|
||||
|
||||
public string target_score2 { get; set; }
|
||||
|
||||
public string target_score3 { get; set; }
|
||||
|
||||
public string target_score4 { get; set; }
|
||||
|
||||
public string target_score5 { get; set; }
|
||||
public int? create_evaluation_detail_id_eva_create_evaluation_detail_create_evaluation_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -141,6 +141,7 @@ namespace TodoAPI2.Models
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
var current_sum = (from i in _repository.Context.eva_evaluation_behavior
|
||||
where i.create_evaluation_detail_id == model.create_evaluation_detail_id
|
||||
select i.weight).Sum();
|
||||
|
||||
if (current_sum + model.weight > 100)
|
||||
@@ -156,6 +157,7 @@ namespace TodoAPI2.Models
|
||||
public eva_evaluation_behaviorViewModel Update(int id, eva_evaluation_behaviorInputModel model)
|
||||
{
|
||||
var current_sum = (from i in _repository.Context.eva_evaluation_behavior
|
||||
where i.create_evaluation_detail_id == model.create_evaluation_detail_id
|
||||
select i.weight).Sum();
|
||||
|
||||
var current_item_weight = (from i in _repository.Context.eva_evaluation_behavior
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
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_level_score_basicService : IBaseService<Guid, eva_level_score_basicInputModel, eva_level_score_basicViewModel>
|
||||
{
|
||||
new eva_level_score_basicViewModel Insert(eva_level_score_basicInputModel model);
|
||||
new eva_level_score_basicViewModel Update(Guid id, eva_level_score_basicInputModel model);
|
||||
List<eva_level_score_basicViewModel> GetListBycode(string code);
|
||||
List<eva_level_score_basicViewModel> GetListBySearch(eva_level_score_basicSearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_level_score_basicInputModel> model);
|
||||
eva_level_score_basicWithSelectionViewModel GetWithSelection(Guid id);
|
||||
eva_level_score_basicWithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_level_score_basicInputModel
|
||||
{
|
||||
|
||||
public Guid? id { get; set; }
|
||||
|
||||
public string code { get; set; }
|
||||
|
||||
public string detail { get; set; }
|
||||
|
||||
public decimal? max_score { get; set; }
|
||||
|
||||
public decimal? min_score { 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_level_score_basicReportRequestModel : eva_level_score_basicSearchModel
|
||||
{
|
||||
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_level_score_basicSearchModel
|
||||
{
|
||||
|
||||
public Guid id { get; set; }
|
||||
|
||||
public string code { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
213
Models/eva_level_score_basic/eva_level_score_basicService.cs
Normal file
213
Models/eva_level_score_basic/eva_level_score_basicService.cs
Normal file
@@ -0,0 +1,213 @@
|
||||
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_level_score_basicService : Ieva_level_score_basicService
|
||||
{
|
||||
private IBaseRepository<eva_level_scoreEntity, Guid> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
|
||||
public eva_level_score_basicService(IBaseRepository<eva_level_scoreEntity, Guid> repository, IMyDatabase mydb, Iexternal_linkageService inext)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_level_scoreEntity GetEntity(eva_level_score_basicInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_level_scoreEntity>(model);
|
||||
}
|
||||
private List<eva_level_scoreEntity> GetEntityList(List<eva_level_score_basicInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_level_scoreEntity>>(models);
|
||||
}
|
||||
private eva_level_score_basicViewModel GetDto(eva_level_scoreEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_level_score_basicViewModel>(entity);
|
||||
}
|
||||
private List<eva_level_score_basicViewModel> GetDtoList(List<eva_level_scoreEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_level_score_basicViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_level_score_basicViewModel Get(Guid id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_level_score_basicWithSelectionViewModel GetWithSelection(Guid id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_level_score_basicWithSelectionViewModel>(entity);
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_level_score_basicWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_level_score_basicWithSelectionViewModel();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_level_score_basicViewModel> GetListBycode(string code)
|
||||
{
|
||||
var model = new eva_level_score_basicSearchModel();
|
||||
model.code = code;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_level_score_basicViewModel> GetListBySearch(eva_level_score_basicSearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_level_score_basic in _repository.Context.eva_level_score
|
||||
|
||||
|
||||
where 1==1
|
||||
//&& (m_eva_level_score_basic.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_level_score_basic.code == model.code || string.IsNullOrEmpty(model.code))
|
||||
|
||||
|
||||
orderby m_eva_level_score_basic.created descending
|
||||
select new eva_level_score_basicViewModel()
|
||||
{
|
||||
id = m_eva_level_score_basic.id,
|
||||
code = m_eva_level_score_basic.code,
|
||||
detail = m_eva_level_score_basic.detail,
|
||||
max_score = m_eva_level_score_basic.max_score,
|
||||
min_score = m_eva_level_score_basic.min_score,
|
||||
|
||||
|
||||
isActive = m_eva_level_score_basic.isActive,
|
||||
Created = m_eva_level_score_basic.created,
|
||||
Updated = m_eva_level_score_basic.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
public eva_level_score_basicViewModel Insert(eva_level_score_basicInputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = Guid.NewGuid();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_level_score_basicViewModel Update(Guid id, eva_level_score_basicInputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.code = model.code;
|
||||
existingEntity.detail = model.detail;
|
||||
existingEntity.max_score = model.max_score;
|
||||
existingEntity.min_score = model.min_score;
|
||||
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_level_score_basicInputModel> 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.code = i.code;
|
||||
existingEntity.detail = i.detail;
|
||||
existingEntity.max_score = i.max_score;
|
||||
existingEntity.min_score = i.min_score;
|
||||
|
||||
|
||||
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
|
||||
}
|
||||
}
|
||||
else if (i.active_mode == "1" && !i.id.HasValue) // add
|
||||
{
|
||||
var entity = GetEntity(i);
|
||||
entity.id = Guid.NewGuid();
|
||||
_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();
|
||||
|
||||
return model.Count().ToString();
|
||||
}
|
||||
|
||||
public eva_level_score_basicViewModel SetAsActive(Guid id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_level_score_basicViewModel SetAsInactive(Guid id)
|
||||
{
|
||||
var updated = _repository.SetAsInActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public void Delete(Guid id)
|
||||
{
|
||||
_repository.Delete(id);
|
||||
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Match Item
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
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_level_score_basicViewModel : BaseViewModel2<Guid>
|
||||
{
|
||||
|
||||
public string code { get; set; }
|
||||
|
||||
public string detail { get; set; }
|
||||
|
||||
public decimal? max_score { get; set; }
|
||||
|
||||
public decimal? min_score { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_level_score_basicWithSelectionViewModel: eva_level_score_basicViewModel
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user