First Initial
This commit is contained in:
11
Models/ErrorViewModel.cs
Normal file
11
Models/ErrorViewModel.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace STAFF_API.Models
|
||||
{
|
||||
public class ErrorViewModel
|
||||
{
|
||||
public string RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
}
|
||||
}
|
||||
@@ -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_adjust_postponementService : IBaseService<int, eva_adjust_postponementInputModel, eva_adjust_postponementViewModel>
|
||||
{
|
||||
new eva_adjust_postponementViewModel Insert(eva_adjust_postponementInputModel model);
|
||||
new eva_adjust_postponementViewModel Update(int id, eva_adjust_postponementInputModel model);
|
||||
List<eva_adjust_postponementViewModel> GetListByfiscal_year(int? fiscal_year);
|
||||
List<eva_adjust_postponementViewModel> GetListBySearch(eva_adjust_postponementSearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_adjust_postponementInputModel> model);
|
||||
eva_adjust_postponementWithSelectionViewModel GetWithSelection(int id);
|
||||
eva_adjust_postponementWithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
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_adjust_postponementEntity : BaseEntity2<int>
|
||||
{
|
||||
|
||||
|
||||
public int? fiscal_year { get; set; }
|
||||
|
||||
public DateTime? theDate { get; set; }
|
||||
|
||||
public int? theRound { get; set; }
|
||||
|
||||
[ForeignKey("create_evaluation_id")]
|
||||
public eva_create_evaluationEntity eva_create_evaluation { get; set; }
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public decimal? limit { get; set; }
|
||||
|
||||
public decimal? limit_frame { get; set; }
|
||||
|
||||
public decimal? limit_quota { get; set; }
|
||||
|
||||
public decimal? limit_frame_quota { get; set; }
|
||||
|
||||
public decimal? percentage { get; set; }
|
||||
|
||||
[MaxLength(100)]
|
||||
public string command_no { get; set; }
|
||||
|
||||
public int? managed_by { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
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_adjust_postponementInputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? fiscal_year { get; set; }
|
||||
|
||||
public DateTime? theDate { get; set; }
|
||||
|
||||
public int? theRound { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public decimal? limit { get; set; }
|
||||
|
||||
public decimal? limit_frame { get; set; }
|
||||
|
||||
public decimal? limit_quota { get; set; }
|
||||
|
||||
public decimal? limit_frame_quota { get; set; }
|
||||
|
||||
public decimal? percentage { get; set; }
|
||||
|
||||
public string command_no { get; set; }
|
||||
|
||||
public int? managed_by { 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_adjust_postponementReportRequestModel : eva_adjust_postponementSearchModel
|
||||
{
|
||||
public string filetype { get; set; }
|
||||
|
||||
public string contentType { get { return MyHelper.GetContentType(filetype); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
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_adjust_postponementSearchModel
|
||||
{
|
||||
|
||||
public int id { get; set; }
|
||||
|
||||
public int? fiscal_year { get; set; }
|
||||
|
||||
public int? theRound { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
272
Models/eva_adjust_postponement/eva_adjust_postponementService.cs
Normal file
272
Models/eva_adjust_postponement/eva_adjust_postponementService.cs
Normal file
@@ -0,0 +1,272 @@
|
||||
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_adjust_postponementService : Ieva_adjust_postponementService
|
||||
{
|
||||
private IBaseRepository2<eva_adjust_postponementEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
|
||||
public eva_adjust_postponementService(IBaseRepository2<eva_adjust_postponementEntity, int> repository,
|
||||
IMyDatabase mydb, Iexternal_linkageService inext,
|
||||
Iexternal_employeeService inemp)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
emp = inemp;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_adjust_postponementEntity GetEntity(eva_adjust_postponementInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_adjust_postponementEntity>(model);
|
||||
}
|
||||
private List<eva_adjust_postponementEntity> GetEntityList(List<eva_adjust_postponementInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_adjust_postponementEntity>>(models);
|
||||
}
|
||||
private eva_adjust_postponementViewModel GetDto(eva_adjust_postponementEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_adjust_postponementViewModel>(entity);
|
||||
}
|
||||
private List<eva_adjust_postponementViewModel> GetDtoList(List<eva_adjust_postponementEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_adjust_postponementViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_adjust_postponementViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_adjust_postponementWithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_adjust_postponementWithSelectionViewModel>(entity);
|
||||
i.item_create_evaluation_id = (from x in _repository.Context.eva_create_evaluation select x).ToList();
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
i.item_managed_by = all_emp.ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_adjust_postponementWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_adjust_postponementWithSelectionViewModel();
|
||||
i.item_create_evaluation_id = (from x in _repository.Context.eva_create_evaluation select x).ToList();
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
i.item_managed_by = all_emp.ToList();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_adjust_postponementViewModel> GetListByfiscal_year(int? fiscal_year)
|
||||
{
|
||||
var model = new eva_adjust_postponementSearchModel();
|
||||
model.fiscal_year = fiscal_year;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_adjust_postponementViewModel> GetListBySearch(eva_adjust_postponementSearchModel model)
|
||||
{
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
var data = (
|
||||
from m_eva_adjust_postponement in _repository.Context.eva_adjust_postponement
|
||||
|
||||
join fk_eva_create_evaluation4 in _repository.Context.eva_create_evaluation on m_eva_adjust_postponement.create_evaluation_id equals fk_eva_create_evaluation4.id
|
||||
into eva_create_evaluationResult4
|
||||
from fk_eva_create_evaluationResult4 in eva_create_evaluationResult4.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage11 in all_emp on m_eva_adjust_postponement.managed_by equals fk_external_linkage11.id
|
||||
into external_linkageResult11
|
||||
from fk_external_linkageResult11 in external_linkageResult11.DefaultIfEmpty()
|
||||
|
||||
|
||||
where 1==1
|
||||
//&& (m_eva_adjust_postponement.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_adjust_postponement.fiscal_year == model.fiscal_year || !model.fiscal_year.HasValue)
|
||||
&& (m_eva_adjust_postponement.theRound == model.theRound || !model.theRound.HasValue)
|
||||
|
||||
|
||||
orderby m_eva_adjust_postponement.created descending
|
||||
select new eva_adjust_postponementViewModel()
|
||||
{
|
||||
id = m_eva_adjust_postponement.id,
|
||||
fiscal_year = m_eva_adjust_postponement.fiscal_year,
|
||||
theDate = m_eva_adjust_postponement.theDate,
|
||||
theRound = m_eva_adjust_postponement.theRound,
|
||||
create_evaluation_id = m_eva_adjust_postponement.create_evaluation_id,
|
||||
limit = m_eva_adjust_postponement.limit,
|
||||
limit_frame = m_eva_adjust_postponement.limit_frame,
|
||||
limit_quota = m_eva_adjust_postponement.limit_quota,
|
||||
limit_frame_quota = m_eva_adjust_postponement.limit_frame_quota,
|
||||
percentage = m_eva_adjust_postponement.percentage,
|
||||
command_no = m_eva_adjust_postponement.command_no,
|
||||
managed_by = m_eva_adjust_postponement.managed_by,
|
||||
|
||||
create_evaluation_id_eva_create_evaluation_performance_plan_id = fk_eva_create_evaluationResult4.performance_plan_id,
|
||||
managed_by_external_linkage_external_name = fk_external_linkageResult11.fullname,
|
||||
|
||||
isActive = m_eva_adjust_postponement.isActive,
|
||||
Created = m_eva_adjust_postponement.created,
|
||||
Updated = m_eva_adjust_postponement.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
public int GetNewPrimaryKey()
|
||||
{
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_adjust_postponement
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if(x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
|
||||
return newkey.Value;
|
||||
}
|
||||
|
||||
public eva_adjust_postponementViewModel Insert(eva_adjust_postponementInputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_adjust_postponementViewModel Update(int id, eva_adjust_postponementInputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.fiscal_year = model.fiscal_year;
|
||||
existingEntity.theDate = model.theDate;
|
||||
existingEntity.theRound = model.theRound;
|
||||
existingEntity.create_evaluation_id = model.create_evaluation_id;
|
||||
existingEntity.limit = model.limit;
|
||||
existingEntity.limit_frame = model.limit_frame;
|
||||
existingEntity.limit_quota = model.limit_quota;
|
||||
existingEntity.limit_frame_quota = model.limit_frame_quota;
|
||||
existingEntity.percentage = model.percentage;
|
||||
existingEntity.command_no = model.command_no;
|
||||
existingEntity.managed_by = model.managed_by;
|
||||
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_adjust_postponementInputModel> 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.limit_frame_quota = i.limit_frame_quota;
|
||||
existingEntity.percentage = i.percentage;
|
||||
existingEntity.command_no = i.command_no;
|
||||
existingEntity.managed_by = i.managed_by;
|
||||
|
||||
|
||||
_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_adjust_postponementViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_adjust_postponementViewModel 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,45 @@
|
||||
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_adjust_postponementViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? fiscal_year { get; set; }
|
||||
|
||||
public DateTime? theDate { get; set; }
|
||||
|
||||
public string txt_theDate { get { return MyHelper.GetDateStringForReport(this.theDate); } }
|
||||
|
||||
public int? theRound { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public decimal? limit { get; set; }
|
||||
|
||||
public decimal? limit_frame { get; set; }
|
||||
|
||||
public decimal? limit_quota { get; set; }
|
||||
|
||||
public decimal? limit_frame_quota { get; set; }
|
||||
|
||||
public decimal? percentage { get; set; }
|
||||
|
||||
public string command_no { get; set; }
|
||||
|
||||
public int? managed_by { get; set; }
|
||||
|
||||
public Guid? create_evaluation_id_eva_create_evaluation_performance_plan_id { get; set; }
|
||||
public string managed_by_external_linkage_external_name { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_adjust_postponementWithSelectionViewModel: eva_adjust_postponementViewModel
|
||||
{
|
||||
public List<eva_create_evaluationEntity> item_create_evaluation_id { get; set; }
|
||||
public List<external_employeeViewModel> item_managed_by { 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_adjust_postponement_detailService : IBaseService<int, eva_adjust_postponement_detailInputModel, eva_adjust_postponement_detailViewModel>
|
||||
{
|
||||
new eva_adjust_postponement_detailViewModel Insert(eva_adjust_postponement_detailInputModel model);
|
||||
new eva_adjust_postponement_detailViewModel Update(int id, eva_adjust_postponement_detailInputModel model);
|
||||
List<eva_adjust_postponement_detailViewModel> GetListByadjust_postponement_id(int? adjust_postponement_id);
|
||||
List<eva_adjust_postponement_detailViewModel> GetListBySearch(eva_adjust_postponement_detailSearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_adjust_postponement_detailInputModel> model);
|
||||
eva_adjust_postponement_detailWithSelectionViewModel GetWithSelection(int id);
|
||||
eva_adjust_postponement_detailWithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
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_adjust_postponement_detailEntity : BaseEntity2<int>
|
||||
{
|
||||
|
||||
|
||||
[ForeignKey("adjust_postponement_id")]
|
||||
public eva_adjust_postponementEntity eva_adjust_postponement { get; set; }
|
||||
public int? adjust_postponement_id { get; set; }
|
||||
|
||||
[ForeignKey("adjust_postponement_quota_id")]
|
||||
public eva_adjust_postponementEntity eva_adjust_postponement_quota { get; set; }
|
||||
public int? adjust_postponement_quota_id { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public decimal? sarary { get; set; }
|
||||
|
||||
public decimal? cost_living { get; set; }
|
||||
|
||||
public decimal? middle { get; set; }
|
||||
|
||||
public decimal? promoted_percentage { get; set; }
|
||||
|
||||
public decimal? total_promote { get; set; }
|
||||
|
||||
public decimal? new_sarary { get; set; }
|
||||
|
||||
public decimal? new_cost_living { get; set; }
|
||||
|
||||
[MaxLength(1000)]
|
||||
public string remark { get; set; }
|
||||
|
||||
public decimal? receive_quota { get; set; }
|
||||
|
||||
public decimal? new_sarary_with_quota { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
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_adjust_postponement_detailInputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? adjust_postponement_id { get; set; }
|
||||
|
||||
public int? adjust_postponement_quota_id { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public decimal? sarary { get; set; }
|
||||
|
||||
public decimal? cost_living { get; set; }
|
||||
|
||||
public decimal? middle { get; set; }
|
||||
|
||||
public decimal? promoted_percentage { get; set; }
|
||||
|
||||
public decimal? total_promote { get; set; }
|
||||
|
||||
public decimal? new_sarary { get; set; }
|
||||
|
||||
public decimal? new_cost_living { get; set; }
|
||||
|
||||
public string remark { get; set; }
|
||||
|
||||
public decimal? receive_quota { get; set; }
|
||||
|
||||
public decimal? new_sarary_with_quota { 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_adjust_postponement_detailReportRequestModel : eva_adjust_postponement_detailSearchModel
|
||||
{
|
||||
public string filetype { get; set; }
|
||||
|
||||
public string contentType { get { return MyHelper.GetContentType(filetype); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
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_adjust_postponement_detailSearchModel
|
||||
{
|
||||
|
||||
public int id { get; set; }
|
||||
|
||||
public int? adjust_postponement_id { get; set; }
|
||||
|
||||
public int? adjust_postponement_quota_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,281 @@
|
||||
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_adjust_postponement_detailService : Ieva_adjust_postponement_detailService
|
||||
{
|
||||
private IBaseRepository2<eva_adjust_postponement_detailEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
|
||||
public eva_adjust_postponement_detailService(IBaseRepository2<eva_adjust_postponement_detailEntity, int> repository,
|
||||
IMyDatabase mydb, Iexternal_linkageService inext, Iexternal_employeeService inemp)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
emp = inemp;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_adjust_postponement_detailEntity GetEntity(eva_adjust_postponement_detailInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_adjust_postponement_detailEntity>(model);
|
||||
}
|
||||
private List<eva_adjust_postponement_detailEntity> GetEntityList(List<eva_adjust_postponement_detailInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_adjust_postponement_detailEntity>>(models);
|
||||
}
|
||||
private eva_adjust_postponement_detailViewModel GetDto(eva_adjust_postponement_detailEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_adjust_postponement_detailViewModel>(entity);
|
||||
}
|
||||
private List<eva_adjust_postponement_detailViewModel> GetDtoList(List<eva_adjust_postponement_detailEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_adjust_postponement_detailViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_adjust_postponement_detailViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_adjust_postponement_detailWithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_adjust_postponement_detailWithSelectionViewModel>(entity);
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
i.item_employee_id = all_emp.ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_adjust_postponement_detailWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_adjust_postponement_detailWithSelectionViewModel();
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
i.item_employee_id = all_emp.ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_adjust_postponement_detailViewModel> GetListByadjust_postponement_id(int? adjust_postponement_id)
|
||||
{
|
||||
var model = new eva_adjust_postponement_detailSearchModel();
|
||||
model.adjust_postponement_id = adjust_postponement_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_adjust_postponement_detailViewModel> GetListBySearch(eva_adjust_postponement_detailSearchModel model)
|
||||
{
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
var data = (
|
||||
from m_eva_adjust_postponement_detail in _repository.Context.eva_adjust_postponement_detail
|
||||
|
||||
join fk_eva_adjust_postponement1 in _repository.Context.eva_adjust_postponement on m_eva_adjust_postponement_detail.adjust_postponement_id equals fk_eva_adjust_postponement1.id
|
||||
into eva_adjust_postponementResult1
|
||||
from fk_eva_adjust_postponementResult1 in eva_adjust_postponementResult1.DefaultIfEmpty()
|
||||
|
||||
join fk_eva_adjust_postponement2 in _repository.Context.eva_adjust_postponement on m_eva_adjust_postponement_detail.adjust_postponement_quota_id equals fk_eva_adjust_postponement2.id
|
||||
into eva_adjust_postponementResult2
|
||||
from fk_eva_adjust_postponementResult2 in eva_adjust_postponementResult2.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage3 in all_emp on m_eva_adjust_postponement_detail.employee_id equals fk_external_linkage3.id
|
||||
into external_linkageResult3
|
||||
from fk_external_linkageResult3 in external_linkageResult3.DefaultIfEmpty()
|
||||
|
||||
|
||||
where 1==1
|
||||
//&& (m_eva_adjust_postponement_detail.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_adjust_postponement_detail.adjust_postponement_id == model.adjust_postponement_id || !model.adjust_postponement_id.HasValue)
|
||||
&& (m_eva_adjust_postponement_detail.adjust_postponement_quota_id == model.adjust_postponement_quota_id || !model.adjust_postponement_quota_id.HasValue)
|
||||
|
||||
|
||||
orderby m_eva_adjust_postponement_detail.created descending
|
||||
select new eva_adjust_postponement_detailViewModel()
|
||||
{
|
||||
id = m_eva_adjust_postponement_detail.id,
|
||||
adjust_postponement_id = m_eva_adjust_postponement_detail.adjust_postponement_id,
|
||||
adjust_postponement_quota_id = m_eva_adjust_postponement_detail.adjust_postponement_quota_id,
|
||||
employee_id = m_eva_adjust_postponement_detail.employee_id,
|
||||
sarary = m_eva_adjust_postponement_detail.sarary,
|
||||
cost_living = m_eva_adjust_postponement_detail.cost_living,
|
||||
middle = m_eva_adjust_postponement_detail.middle,
|
||||
promoted_percentage = m_eva_adjust_postponement_detail.promoted_percentage,
|
||||
total_promote = m_eva_adjust_postponement_detail.total_promote,
|
||||
new_sarary = m_eva_adjust_postponement_detail.new_sarary,
|
||||
new_cost_living = m_eva_adjust_postponement_detail.new_cost_living,
|
||||
remark = m_eva_adjust_postponement_detail.remark,
|
||||
receive_quota = m_eva_adjust_postponement_detail.receive_quota,
|
||||
new_sarary_with_quota = m_eva_adjust_postponement_detail.new_sarary_with_quota,
|
||||
|
||||
adjust_postponement_id_eva_adjust_postponement_fiscal_year = fk_eva_adjust_postponementResult1.fiscal_year,
|
||||
adjust_postponement_quota_id_eva_adjust_postponement_fiscal_year = fk_eva_adjust_postponementResult2.fiscal_year,
|
||||
employee_id_external_linkage_external_name = fk_external_linkageResult3.fullname,
|
||||
|
||||
isActive = m_eva_adjust_postponement_detail.isActive,
|
||||
Created = m_eva_adjust_postponement_detail.created,
|
||||
Updated = m_eva_adjust_postponement_detail.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
public int GetNewPrimaryKey()
|
||||
{
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_adjust_postponement_detail
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if(x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
|
||||
return newkey.Value;
|
||||
}
|
||||
|
||||
public eva_adjust_postponement_detailViewModel Insert(eva_adjust_postponement_detailInputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_adjust_postponement_detailViewModel Update(int id, eva_adjust_postponement_detailInputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.adjust_postponement_id = model.adjust_postponement_id;
|
||||
existingEntity.adjust_postponement_quota_id = model.adjust_postponement_quota_id;
|
||||
existingEntity.employee_id = model.employee_id;
|
||||
existingEntity.sarary = model.sarary;
|
||||
existingEntity.cost_living = model.cost_living;
|
||||
existingEntity.middle = model.middle;
|
||||
existingEntity.promoted_percentage = model.promoted_percentage;
|
||||
existingEntity.total_promote = model.total_promote;
|
||||
existingEntity.new_sarary = model.new_sarary;
|
||||
existingEntity.new_cost_living = model.new_cost_living;
|
||||
existingEntity.remark = model.remark;
|
||||
existingEntity.receive_quota = model.receive_quota;
|
||||
existingEntity.new_sarary_with_quota = model.new_sarary_with_quota;
|
||||
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_adjust_postponement_detailInputModel> 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.adjust_postponement_id = i.adjust_postponement_id;
|
||||
existingEntity.adjust_postponement_quota_id = i.adjust_postponement_quota_id;
|
||||
existingEntity.employee_id = i.employee_id;
|
||||
existingEntity.sarary = i.sarary;
|
||||
existingEntity.cost_living = i.cost_living;
|
||||
existingEntity.middle = i.middle;
|
||||
existingEntity.promoted_percentage = i.promoted_percentage;
|
||||
existingEntity.total_promote = i.total_promote;
|
||||
existingEntity.new_sarary = i.new_sarary;
|
||||
existingEntity.new_cost_living = i.new_cost_living;
|
||||
existingEntity.remark = i.remark;
|
||||
existingEntity.receive_quota = i.receive_quota;
|
||||
existingEntity.new_sarary_with_quota = i.new_sarary_with_quota;
|
||||
|
||||
|
||||
_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_adjust_postponement_detailViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_adjust_postponement_detailViewModel 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,48 @@
|
||||
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_adjust_postponement_detailViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? adjust_postponement_id { get; set; }
|
||||
|
||||
public int? adjust_postponement_quota_id { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public decimal? sarary { get; set; }
|
||||
|
||||
public decimal? cost_living { get; set; }
|
||||
|
||||
public decimal? middle { get; set; }
|
||||
|
||||
public decimal? promoted_percentage { get; set; }
|
||||
|
||||
public decimal? total_promote { get; set; }
|
||||
|
||||
public decimal? new_sarary { get; set; }
|
||||
|
||||
public decimal? new_cost_living { get; set; }
|
||||
|
||||
public string remark { get; set; }
|
||||
|
||||
public decimal? receive_quota { get; set; }
|
||||
|
||||
public decimal? new_sarary_with_quota { get; set; }
|
||||
|
||||
public int? adjust_postponement_id_eva_adjust_postponement_fiscal_year { get; set; }
|
||||
public int? adjust_postponement_quota_id_eva_adjust_postponement_fiscal_year { get; set; }
|
||||
public string employee_id_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_adjust_postponement_detailWithSelectionViewModel: eva_adjust_postponement_detailViewModel
|
||||
{
|
||||
public List<external_employeeViewModel> item_employee_id { 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_adjust_postponement_detail_normalService : IBaseService<int, eva_adjust_postponement_detail_normalInputModel, eva_adjust_postponement_detail_normalViewModel>
|
||||
{
|
||||
new eva_adjust_postponement_detail_normalViewModel Insert(eva_adjust_postponement_detail_normalInputModel model);
|
||||
new eva_adjust_postponement_detail_normalViewModel Update(int id, eva_adjust_postponement_detail_normalInputModel model);
|
||||
List<eva_adjust_postponement_detail_normalViewModel> GetListByadjust_postponement_id(int? adjust_postponement_id);
|
||||
List<eva_adjust_postponement_detail_normalViewModel> GetListBySearch(eva_adjust_postponement_detail_normalSearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_adjust_postponement_detail_normalInputModel> model);
|
||||
eva_adjust_postponement_detail_normalWithSelectionViewModel GetWithSelection(int id);
|
||||
eva_adjust_postponement_detail_normalWithSelectionViewModel GetBlankItem();
|
||||
|
||||
string ReCreatePostponementDetailNormal(int? adjust_postponement_id);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
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_adjust_postponement_detail_normalInputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? adjust_postponement_id { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public decimal? sarary { get; set; }
|
||||
|
||||
public decimal? cost_living { get; set; }
|
||||
|
||||
public decimal? middle { get; set; }
|
||||
|
||||
public decimal? promoted_percentage { get; set; }
|
||||
|
||||
public decimal? total_promote { get; set; }
|
||||
|
||||
public decimal? new_sarary { get; set; }
|
||||
|
||||
public decimal? new_cost_living { get; set; }
|
||||
|
||||
public string remark { get; set; }
|
||||
|
||||
public string emp_code { get; set; }
|
||||
|
||||
public string emp_fullname { get; set; }
|
||||
|
||||
public string emp_position { get; set; }
|
||||
|
||||
public string emp_level { get; set; }
|
||||
|
||||
public decimal? total_score { get; set; }
|
||||
|
||||
public string eva_result { 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_adjust_postponement_detail_normalReportRequestModel : eva_adjust_postponement_detail_normalSearchModel
|
||||
{
|
||||
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_adjust_postponement_detail_normalSearchModel
|
||||
{
|
||||
|
||||
public int id { get; set; }
|
||||
|
||||
public int? adjust_postponement_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,371 @@
|
||||
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_adjust_postponement_detail_normalService : Ieva_adjust_postponement_detail_normalService
|
||||
{
|
||||
private IBaseRepository2<eva_adjust_postponement_detailEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
|
||||
public eva_adjust_postponement_detail_normalService(IBaseRepository2<eva_adjust_postponement_detailEntity, int> repository,
|
||||
IMyDatabase mydb, Iexternal_linkageService inext, Iexternal_employeeService inemp)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
emp = inemp;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_adjust_postponement_detailEntity GetEntity(eva_adjust_postponement_detail_normalInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_adjust_postponement_detailEntity>(model);
|
||||
}
|
||||
private List<eva_adjust_postponement_detailEntity> GetEntityList(List<eva_adjust_postponement_detail_normalInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_adjust_postponement_detailEntity>>(models);
|
||||
}
|
||||
private eva_adjust_postponement_detail_normalViewModel GetDto(eva_adjust_postponement_detailEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_adjust_postponement_detail_normalViewModel>(entity);
|
||||
}
|
||||
private List<eva_adjust_postponement_detail_normalViewModel> GetDtoList(List<eva_adjust_postponement_detailEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_adjust_postponement_detail_normalViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_adjust_postponement_detail_normalViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_adjust_postponement_detail_normalWithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_adjust_postponement_detail_normalWithSelectionViewModel>(entity);
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
i.item_employee_id = all_emp.ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_adjust_postponement_detail_normalWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_adjust_postponement_detail_normalWithSelectionViewModel();
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
i.item_employee_id = all_emp.ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_adjust_postponement_detail_normalViewModel> GetListByadjust_postponement_id(int? adjust_postponement_id)
|
||||
{
|
||||
var model = new eva_adjust_postponement_detail_normalSearchModel();
|
||||
model.adjust_postponement_id = adjust_postponement_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_adjust_postponement_detail_normalViewModel> GetListBySearch(eva_adjust_postponement_detail_normalSearchModel model)
|
||||
{
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
var data = (
|
||||
from m_eva_adjust_postponement_detail_normal in _repository.Context.eva_adjust_postponement_detail
|
||||
|
||||
join fk_eva_adjust_postponement1 in _repository.Context.eva_adjust_postponement on m_eva_adjust_postponement_detail_normal.adjust_postponement_id equals fk_eva_adjust_postponement1.id
|
||||
into eva_adjust_postponementResult1
|
||||
from fk_eva_adjust_postponementResult1 in eva_adjust_postponementResult1.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage2 in all_emp on m_eva_adjust_postponement_detail_normal.employee_id equals fk_external_linkage2.id
|
||||
into external_linkageResult2
|
||||
from fk_external_linkageResult2 in external_linkageResult2.DefaultIfEmpty()
|
||||
|
||||
join create_detail in _repository.Context.eva_create_evaluation_detail
|
||||
on fk_eva_adjust_postponementResult1.create_evaluation_id equals create_detail.create_evaluation_id
|
||||
into create_detailResult
|
||||
from fk_create_detailResult in create_detailResult.DefaultIfEmpty()
|
||||
|
||||
where 1==1
|
||||
//&& (m_eva_adjust_postponement_detail_normal.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_adjust_postponement_detail_normal.adjust_postponement_id == model.adjust_postponement_id || !model.adjust_postponement_id.HasValue)
|
||||
&& fk_create_detailResult.employee_id == m_eva_adjust_postponement_detail_normal.employee_id
|
||||
|
||||
orderby m_eva_adjust_postponement_detail_normal.created descending
|
||||
select new eva_adjust_postponement_detail_normalViewModel()
|
||||
{
|
||||
id = m_eva_adjust_postponement_detail_normal.id,
|
||||
adjust_postponement_id = m_eva_adjust_postponement_detail_normal.adjust_postponement_id,
|
||||
employee_id = m_eva_adjust_postponement_detail_normal.employee_id,
|
||||
sarary = m_eva_adjust_postponement_detail_normal.sarary,
|
||||
cost_living = m_eva_adjust_postponement_detail_normal.cost_living,
|
||||
middle = m_eva_adjust_postponement_detail_normal.middle,
|
||||
promoted_percentage = m_eva_adjust_postponement_detail_normal.promoted_percentage,
|
||||
total_promote = m_eva_adjust_postponement_detail_normal.total_promote,
|
||||
new_sarary = m_eva_adjust_postponement_detail_normal.new_sarary,
|
||||
new_cost_living = m_eva_adjust_postponement_detail_normal.new_cost_living,
|
||||
remark = m_eva_adjust_postponement_detail_normal.remark,
|
||||
emp_code = fk_external_linkageResult2.employee_no,
|
||||
emp_fullname = fk_external_linkageResult2.fullname,
|
||||
emp_position = fk_external_linkageResult2.position_name,
|
||||
emp_level = fk_external_linkageResult2.position_level_text,
|
||||
total_score = fk_create_detailResult.score_supervisor,
|
||||
eva_result = fk_create_detailResult.level_score_supervisor,
|
||||
|
||||
adjust_postponement_id_eva_adjust_postponement_fiscal_year = fk_eva_adjust_postponementResult1.fiscal_year,
|
||||
employee_id_external_linkage_external_name = fk_external_linkageResult2.fullname,
|
||||
|
||||
isActive = m_eva_adjust_postponement_detail_normal.isActive,
|
||||
Created = m_eva_adjust_postponement_detail_normal.created,
|
||||
Updated = m_eva_adjust_postponement_detail_normal.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
public int GetNewPrimaryKey()
|
||||
{
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_adjust_postponement_detail
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if(x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
|
||||
return newkey.Value;
|
||||
}
|
||||
|
||||
public eva_adjust_postponement_detail_normalViewModel Insert(eva_adjust_postponement_detail_normalInputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_adjust_postponement_detail_normalViewModel Update(int id, eva_adjust_postponement_detail_normalInputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.adjust_postponement_id = model.adjust_postponement_id;
|
||||
existingEntity.employee_id = model.employee_id;
|
||||
existingEntity.sarary = model.sarary;
|
||||
existingEntity.cost_living = model.cost_living;
|
||||
existingEntity.middle = model.middle;
|
||||
existingEntity.promoted_percentage = model.promoted_percentage;
|
||||
existingEntity.total_promote = model.total_promote;
|
||||
existingEntity.new_sarary = model.new_sarary;
|
||||
existingEntity.new_cost_living = model.new_cost_living;
|
||||
existingEntity.remark = model.remark;
|
||||
//existingEntity.emp_code = model.emp_code;
|
||||
//existingEntity.emp_fullname = model.emp_fullname;
|
||||
//existingEntity.emp_position = model.emp_position;
|
||||
//existingEntity.emp_level = model.emp_level;
|
||||
//existingEntity.total_score = model.total_score;
|
||||
//existingEntity.eva_result = model.eva_result;
|
||||
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string ReCreatePostponementDetailNormal(int? adjust_postponement_id)
|
||||
{
|
||||
var cylinder = (from z in _repository.Context.eva_salary_cylinder
|
||||
select z).ToList();
|
||||
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
var olddata = from i in _repository.Context.eva_adjust_postponement_detail
|
||||
where i.adjust_postponement_id == adjust_postponement_id
|
||||
select i;
|
||||
_repository.Context.RemoveRange(olddata);
|
||||
|
||||
var adjust_postponement = (from j in _repository.Context.eva_adjust_postponement
|
||||
where j.id == adjust_postponement_id
|
||||
select j).FirstOrDefault();
|
||||
|
||||
var current_eva_create_evaluation_detail = from k in _repository.Context.eva_create_evaluation_detail
|
||||
where k.create_evaluation_id == adjust_postponement.create_evaluation_id
|
||||
select k;
|
||||
|
||||
int newkey = GetNewPrimaryKey();
|
||||
|
||||
foreach (var m in current_eva_create_evaluation_detail)
|
||||
{
|
||||
var theemp = (from i in all_emp where i.id == m.employee_id select i).FirstOrDefault();
|
||||
|
||||
var n = new eva_adjust_postponement_detailEntity();
|
||||
n.id = newkey;
|
||||
newkey++;
|
||||
n.adjust_postponement_id = adjust_postponement_id;
|
||||
n.adjust_postponement_quota_id = null;
|
||||
n.employee_id = m.employee_id;
|
||||
|
||||
if (theemp.salary.HasValue)
|
||||
{
|
||||
n.sarary = theemp.salary;
|
||||
}
|
||||
else
|
||||
{
|
||||
n.sarary = 0;
|
||||
}
|
||||
|
||||
var c = getCylinderForEmployee(theemp, cylinder);
|
||||
|
||||
n.cost_living = 0;
|
||||
n.middle = 0;
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
n.middle = c.middle;
|
||||
n.cost_living = c.cost_living;
|
||||
}
|
||||
|
||||
n.promoted_percentage = 0;
|
||||
n.total_promote = 0;
|
||||
n.new_sarary = n.sarary;
|
||||
n.new_cost_living = n.cost_living;
|
||||
n.remark = null;
|
||||
n.receive_quota = 0;
|
||||
n.new_sarary_with_quota = n.sarary;
|
||||
|
||||
n.created = DateTime.Now;
|
||||
n.updated = DateTime.Now;
|
||||
n.isActive = true;
|
||||
|
||||
_repository.Context.eva_adjust_postponement_detail.Add(n);
|
||||
}
|
||||
|
||||
_repository.Context.SaveChanges();
|
||||
|
||||
return current_eva_create_evaluation_detail.Count().ToString();
|
||||
}
|
||||
|
||||
private eva_salary_cylinderEntity getCylinderForEmployee(external_employeeViewModel theemp,
|
||||
List<eva_salary_cylinderEntity> all_cylinder)
|
||||
{
|
||||
var c = (from i in all_cylinder
|
||||
where i.position_level == theemp.position_level_id
|
||||
&& i.position_type == theemp.position_type_id
|
||||
select i).FirstOrDefault();
|
||||
return c;
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_adjust_postponement_detail_normalInputModel> 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.adjust_postponement_id = i.adjust_postponement_id;
|
||||
existingEntity.employee_id = i.employee_id;
|
||||
existingEntity.sarary = i.sarary;
|
||||
existingEntity.cost_living = i.cost_living;
|
||||
existingEntity.middle = i.middle;
|
||||
existingEntity.promoted_percentage = i.promoted_percentage;
|
||||
existingEntity.total_promote = i.total_promote;
|
||||
existingEntity.new_sarary = i.new_sarary;
|
||||
existingEntity.new_cost_living = i.new_cost_living;
|
||||
existingEntity.remark = i.remark;
|
||||
//existingEntity.emp_code = i.emp_code;
|
||||
//existingEntity.emp_fullname = i.emp_fullname;
|
||||
//existingEntity.emp_position = i.emp_position;
|
||||
//existingEntity.emp_level = i.emp_level;
|
||||
//existingEntity.total_score = i.total_score;
|
||||
//existingEntity.eva_result = i.eva_result;
|
||||
|
||||
|
||||
_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_adjust_postponement_detail_normalViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_adjust_postponement_detail_normalViewModel 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,53 @@
|
||||
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_adjust_postponement_detail_normalViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? adjust_postponement_id { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public decimal? sarary { get; set; }
|
||||
|
||||
public decimal? cost_living { get; set; }
|
||||
|
||||
public decimal? middle { get; set; }
|
||||
|
||||
public decimal? promoted_percentage { get; set; }
|
||||
|
||||
public decimal? total_promote { get; set; }
|
||||
|
||||
public decimal? new_sarary { get; set; }
|
||||
|
||||
public decimal? new_cost_living { get; set; }
|
||||
|
||||
public string remark { get; set; }
|
||||
|
||||
public string emp_code { get; set; }
|
||||
|
||||
public string emp_fullname { get; set; }
|
||||
|
||||
public string emp_position { get; set; }
|
||||
|
||||
public string emp_level { get; set; }
|
||||
|
||||
public decimal? total_score { get; set; }
|
||||
|
||||
public string eva_result { get; set; }
|
||||
|
||||
public int? adjust_postponement_id_eva_adjust_postponement_fiscal_year { get; set; }
|
||||
public string employee_id_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_adjust_postponement_detail_normalWithSelectionViewModel: eva_adjust_postponement_detail_normalViewModel
|
||||
{
|
||||
public List<external_employeeViewModel> item_employee_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
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_adjust_postponement_detail_quotaService : IBaseService<int, eva_adjust_postponement_detail_quotaInputModel, eva_adjust_postponement_detail_quotaViewModel>
|
||||
{
|
||||
new eva_adjust_postponement_detail_quotaViewModel Insert(eva_adjust_postponement_detail_quotaInputModel model);
|
||||
new eva_adjust_postponement_detail_quotaViewModel Update(int id, eva_adjust_postponement_detail_quotaInputModel model);
|
||||
List<eva_adjust_postponement_detail_quotaViewModel> GetListByadjust_postponement_quota_id(int? adjust_postponement_quota_id);
|
||||
List<eva_adjust_postponement_detail_quotaViewModel> GetListBySearch(eva_adjust_postponement_detail_quotaSearchModel model);
|
||||
string UpdateMultiple(List<eva_adjust_postponement_detail_quotaInputModel> model);
|
||||
eva_adjust_postponement_detail_quotaWithSelectionViewModel GetWithSelection(int id);
|
||||
eva_adjust_postponement_detail_quotaWithSelectionViewModel GetBlankItem();
|
||||
string AddMultiple(int? adjust_postponement_quota_id, List<int> model, int? fiscal_year, int? theRound);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
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_adjust_postponement_detail_quotaInputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? adjust_postponement_quota_id { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public decimal? sarary { get; set; }
|
||||
|
||||
public decimal? cost_living { get; set; }
|
||||
|
||||
public decimal? middle { get; set; }
|
||||
|
||||
public decimal? promoted_percentage { get; set; }
|
||||
|
||||
public decimal? total_promote { get; set; }
|
||||
|
||||
public decimal? new_sarary { get; set; }
|
||||
|
||||
public decimal? new_cost_living { get; set; }
|
||||
|
||||
public string remark { get; set; }
|
||||
|
||||
public decimal? receive_quota { get; set; }
|
||||
|
||||
public decimal? new_sarary_with_quota { get; set; }
|
||||
|
||||
public string emp_code { get; set; }
|
||||
|
||||
public string emp_fullname { get; set; }
|
||||
|
||||
public string emp_position { get; set; }
|
||||
|
||||
public string emp_level { get; set; }
|
||||
|
||||
public decimal? total_score { get; set; }
|
||||
|
||||
public string eva_result { 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_adjust_postponement_detail_quotaReportRequestModel : eva_adjust_postponement_detail_quotaSearchModel
|
||||
{
|
||||
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_adjust_postponement_detail_quotaSearchModel
|
||||
{
|
||||
|
||||
public int id { get; set; }
|
||||
|
||||
public int? adjust_postponement_quota_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,365 @@
|
||||
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_adjust_postponement_detail_quotaService : Ieva_adjust_postponement_detail_quotaService
|
||||
{
|
||||
private IBaseRepository2<eva_adjust_postponement_detailEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
|
||||
public eva_adjust_postponement_detail_quotaService(IBaseRepository2<eva_adjust_postponement_detailEntity, int> repository,
|
||||
IMyDatabase mydb, Iexternal_linkageService inext, Iexternal_employeeService inemp)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
emp = inemp;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_adjust_postponement_detailEntity GetEntity(eva_adjust_postponement_detail_quotaInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_adjust_postponement_detailEntity>(model);
|
||||
}
|
||||
private List<eva_adjust_postponement_detailEntity> GetEntityList(List<eva_adjust_postponement_detail_quotaInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_adjust_postponement_detailEntity>>(models);
|
||||
}
|
||||
private eva_adjust_postponement_detail_quotaViewModel GetDto(eva_adjust_postponement_detailEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_adjust_postponement_detail_quotaViewModel>(entity);
|
||||
}
|
||||
private List<eva_adjust_postponement_detail_quotaViewModel> GetDtoList(List<eva_adjust_postponement_detailEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_adjust_postponement_detail_quotaViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_adjust_postponement_detail_quotaViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_adjust_postponement_detail_quotaWithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_adjust_postponement_detail_quotaWithSelectionViewModel>(entity);
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
i.item_employee_id = all_emp.ToList();
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_adjust_postponement_detail_quotaWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_adjust_postponement_detail_quotaWithSelectionViewModel();
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
i.item_employee_id = all_emp.ToList();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_adjust_postponement_detail_quotaViewModel> GetListByadjust_postponement_quota_id(int? adjust_postponement_quota_id)
|
||||
{
|
||||
var model = new eva_adjust_postponement_detail_quotaSearchModel();
|
||||
model.adjust_postponement_quota_id = adjust_postponement_quota_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_adjust_postponement_detail_quotaViewModel> GetListBySearch(eva_adjust_postponement_detail_quotaSearchModel model)
|
||||
{
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
var data = (
|
||||
from m_eva_adjust_postponement_detail_quota in _repository.Context.eva_adjust_postponement_detail
|
||||
|
||||
join fk_eva_adjust_postponement1 in _repository.Context.eva_adjust_postponement on m_eva_adjust_postponement_detail_quota.adjust_postponement_quota_id equals fk_eva_adjust_postponement1.id
|
||||
into eva_adjust_postponementResult1
|
||||
from fk_eva_adjust_postponementResult1 in eva_adjust_postponementResult1.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage2 in all_emp on m_eva_adjust_postponement_detail_quota.employee_id equals fk_external_linkage2.id
|
||||
into external_linkageResult2
|
||||
from fk_external_linkageResult2 in external_linkageResult2.DefaultIfEmpty()
|
||||
|
||||
join create_detail in _repository.Context.eva_create_evaluation_detail
|
||||
on fk_eva_adjust_postponementResult1.create_evaluation_id equals create_detail.create_evaluation_id
|
||||
into create_detailResult
|
||||
from fk_create_detailResult in create_detailResult.DefaultIfEmpty()
|
||||
|
||||
where 1==1
|
||||
//&& (m_eva_adjust_postponement_detail_quota.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_adjust_postponement_detail_quota.adjust_postponement_quota_id == model.adjust_postponement_quota_id || !model.adjust_postponement_quota_id.HasValue)
|
||||
//&& fk_create_detailResult.employee_id == m_eva_adjust_postponement_detail_quota.employee_id
|
||||
|
||||
orderby m_eva_adjust_postponement_detail_quota.created descending
|
||||
select new eva_adjust_postponement_detail_quotaViewModel()
|
||||
{
|
||||
id = m_eva_adjust_postponement_detail_quota.id,
|
||||
adjust_postponement_quota_id = m_eva_adjust_postponement_detail_quota.adjust_postponement_quota_id,
|
||||
employee_id = m_eva_adjust_postponement_detail_quota.employee_id,
|
||||
sarary = m_eva_adjust_postponement_detail_quota.sarary,
|
||||
cost_living = m_eva_adjust_postponement_detail_quota.cost_living,
|
||||
middle = m_eva_adjust_postponement_detail_quota.middle,
|
||||
promoted_percentage = m_eva_adjust_postponement_detail_quota.promoted_percentage,
|
||||
total_promote = m_eva_adjust_postponement_detail_quota.total_promote,
|
||||
new_sarary = m_eva_adjust_postponement_detail_quota.new_sarary,
|
||||
new_cost_living = m_eva_adjust_postponement_detail_quota.new_cost_living,
|
||||
remark = m_eva_adjust_postponement_detail_quota.remark,
|
||||
receive_quota = m_eva_adjust_postponement_detail_quota.receive_quota,
|
||||
new_sarary_with_quota = m_eva_adjust_postponement_detail_quota.new_sarary_with_quota,
|
||||
emp_code = fk_external_linkageResult2.employee_no,
|
||||
emp_fullname = fk_external_linkageResult2.fullname,
|
||||
emp_position = fk_external_linkageResult2.position_name,
|
||||
emp_level = fk_external_linkageResult2.position_level_text,
|
||||
total_score = fk_create_detailResult.score_supervisor,
|
||||
eva_result = fk_create_detailResult.level_score_supervisor,
|
||||
|
||||
adjust_postponement_quota_id_eva_adjust_postponement_fiscal_year = fk_eva_adjust_postponementResult1.fiscal_year,
|
||||
employee_id_external_linkage_external_name = fk_external_linkageResult2.fullname,
|
||||
|
||||
isActive = m_eva_adjust_postponement_detail_quota.isActive,
|
||||
Created = m_eva_adjust_postponement_detail_quota.created,
|
||||
Updated = m_eva_adjust_postponement_detail_quota.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
public int GetNewPrimaryKey()
|
||||
{
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_adjust_postponement_detail
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if(x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
|
||||
return newkey.Value;
|
||||
}
|
||||
|
||||
public eva_adjust_postponement_detail_quotaViewModel Insert(eva_adjust_postponement_detail_quotaInputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_adjust_postponement_detail_quotaViewModel Update(int id, eva_adjust_postponement_detail_quotaInputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.adjust_postponement_quota_id = model.adjust_postponement_quota_id;
|
||||
existingEntity.employee_id = model.employee_id;
|
||||
existingEntity.sarary = model.sarary;
|
||||
existingEntity.cost_living = model.cost_living;
|
||||
existingEntity.middle = model.middle;
|
||||
existingEntity.promoted_percentage = model.promoted_percentage;
|
||||
existingEntity.total_promote = model.total_promote;
|
||||
existingEntity.new_sarary = model.new_sarary;
|
||||
existingEntity.new_cost_living = model.new_cost_living;
|
||||
existingEntity.remark = model.remark;
|
||||
existingEntity.receive_quota = model.receive_quota;
|
||||
existingEntity.new_sarary_with_quota = model.new_sarary_with_quota;
|
||||
//existingEntity.emp_code = model.emp_code;
|
||||
//existingEntity.emp_fullname = model.emp_fullname;
|
||||
//existingEntity.emp_position = model.emp_position;
|
||||
//existingEntity.emp_level = model.emp_level;
|
||||
//existingEntity.total_score = model.total_score;
|
||||
//existingEntity.eva_result = model.eva_result;
|
||||
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_adjust_postponement_detail_quotaInputModel> 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.adjust_postponement_quota_id = i.adjust_postponement_quota_id;
|
||||
existingEntity.employee_id = i.employee_id;
|
||||
existingEntity.sarary = i.sarary;
|
||||
existingEntity.cost_living = i.cost_living;
|
||||
existingEntity.middle = i.middle;
|
||||
existingEntity.promoted_percentage = i.promoted_percentage;
|
||||
existingEntity.total_promote = i.total_promote;
|
||||
existingEntity.new_sarary = i.new_sarary;
|
||||
existingEntity.new_cost_living = i.new_cost_living;
|
||||
existingEntity.remark = i.remark;
|
||||
existingEntity.receive_quota = i.receive_quota;
|
||||
existingEntity.new_sarary_with_quota = i.new_sarary_with_quota;
|
||||
//existingEntity.emp_code = i.emp_code;
|
||||
//existingEntity.emp_fullname = i.emp_fullname;
|
||||
//existingEntity.emp_position = i.emp_position;
|
||||
//existingEntity.emp_level = i.emp_level;
|
||||
//existingEntity.total_score = i.total_score;
|
||||
//existingEntity.eva_result = i.eva_result;
|
||||
|
||||
|
||||
_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 string AddMultiple(int? adjust_postponement_quota_id, List<int> model, int? fiscal_year, int? theRound)
|
||||
{
|
||||
if (!adjust_postponement_quota_id.HasValue)
|
||||
{
|
||||
return "0";
|
||||
}
|
||||
else
|
||||
{
|
||||
int k = 0;
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
var ex = (from x in _repository.Context.eva_adjust_postponement_detail
|
||||
where x.adjust_postponement_quota_id == adjust_postponement_quota_id
|
||||
select x.employee_id).ToList();
|
||||
|
||||
foreach (var i in model)
|
||||
{
|
||||
if (checkExistEmployeeInExternal(i, all_emp))
|
||||
{
|
||||
if (!checkExistEmployeeInInternal(i, ex))
|
||||
{
|
||||
var q = (from p in _repository.Context.eva_adjust_postponement_detail
|
||||
where p.employee_id == i
|
||||
&& p.eva_adjust_postponement.fiscal_year == fiscal_year
|
||||
&& p.eva_adjust_postponement.theRound == theRound
|
||||
select p).FirstOrDefault();
|
||||
|
||||
if(q != null)
|
||||
{
|
||||
q.adjust_postponement_quota_id = adjust_postponement_quota_id;
|
||||
q.updated = DateTime.Now;
|
||||
q.isActive = true;
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_repository.Context.SaveChanges();
|
||||
return k.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private bool checkExistEmployeeInExternal(int emp_id, List<external_employeeViewModel> emp)
|
||||
{
|
||||
foreach (var i in emp)
|
||||
{
|
||||
if (i.id == emp_id) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool checkExistEmployeeInInternal(int emp_id, List<int?> ex)
|
||||
{
|
||||
foreach (var i in ex)
|
||||
{
|
||||
if (i.Value == emp_id) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public eva_adjust_postponement_detail_quotaViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_adjust_postponement_detail_quotaViewModel SetAsInactive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsInActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public void Delete(int id)
|
||||
{
|
||||
//_repository.Delete(id);
|
||||
|
||||
var ex = (from x in _repository.Context.eva_adjust_postponement_detail
|
||||
where x.id == id
|
||||
select x).FirstOrDefault();
|
||||
if(ex != null)
|
||||
{
|
||||
ex.adjust_postponement_quota_id = null;
|
||||
}
|
||||
_repository.Context.SaveChanges();
|
||||
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Match Item
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
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_adjust_postponement_detail_quotaViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? adjust_postponement_quota_id { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public decimal? sarary { get; set; }
|
||||
|
||||
public decimal? cost_living { get; set; }
|
||||
|
||||
public decimal? middle { get; set; }
|
||||
|
||||
public decimal? promoted_percentage { get; set; }
|
||||
|
||||
public decimal? total_promote { get; set; }
|
||||
|
||||
public decimal? new_sarary { get; set; }
|
||||
|
||||
public decimal? new_cost_living { get; set; }
|
||||
|
||||
public string remark { get; set; }
|
||||
|
||||
public decimal? receive_quota { get; set; }
|
||||
|
||||
public decimal? new_sarary_with_quota { get; set; }
|
||||
|
||||
public string emp_code { get; set; }
|
||||
|
||||
public string emp_fullname { get; set; }
|
||||
|
||||
public string emp_position { get; set; }
|
||||
|
||||
public string emp_level { get; set; }
|
||||
|
||||
public decimal? total_score { get; set; }
|
||||
|
||||
public string eva_result { get; set; }
|
||||
|
||||
public int? adjust_postponement_quota_id_eva_adjust_postponement_fiscal_year { get; set; }
|
||||
public string employee_id_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_adjust_postponement_detail_quotaWithSelectionViewModel: eva_adjust_postponement_detail_quotaViewModel
|
||||
{
|
||||
public List<external_employeeViewModel> item_employee_id { 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_adjust_postponement_normalService : IBaseService<int, eva_adjust_postponement_normalInputModel, eva_adjust_postponement_normalViewModel>
|
||||
{
|
||||
new eva_adjust_postponement_normalViewModel Insert(eva_adjust_postponement_normalInputModel model);
|
||||
new eva_adjust_postponement_normalViewModel Update(int id, eva_adjust_postponement_normalInputModel model);
|
||||
List<eva_adjust_postponement_normalViewModel> GetListByfiscal_year(int? fiscal_year);
|
||||
List<eva_adjust_postponement_normalViewModel> GetListBySearch(eva_adjust_postponement_normalSearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_adjust_postponement_normalInputModel> model);
|
||||
eva_adjust_postponement_normalWithSelectionViewModel GetWithSelection(int id);
|
||||
eva_adjust_postponement_normalWithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_adjust_postponement_normalInputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? fiscal_year { get; set; }
|
||||
|
||||
public DateTime? theDate { get; set; }
|
||||
|
||||
public int? theRound { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public decimal? limit { get; set; }
|
||||
|
||||
public decimal? limit_frame { get; set; }
|
||||
|
||||
public decimal? limit_quota { get; set; }
|
||||
|
||||
public decimal? percentage { get; set; }
|
||||
|
||||
public int? managed_by { get; set; }
|
||||
|
||||
//public int? org_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_adjust_postponement_normalReportRequestModel : eva_adjust_postponement_normalSearchModel
|
||||
{
|
||||
public string filetype { get; set; }
|
||||
|
||||
public string contentType { get { return MyHelper.GetContentType(filetype); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_adjust_postponement_normalSearchModel
|
||||
{
|
||||
|
||||
public int id { get; set; }
|
||||
|
||||
public int? fiscal_year { get; set; }
|
||||
|
||||
public int? theRound { get; set; }
|
||||
|
||||
public int? org_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,290 @@
|
||||
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_adjust_postponement_normalService : Ieva_adjust_postponement_normalService
|
||||
{
|
||||
private IBaseRepository2<eva_adjust_postponementEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
private Ieva_create_evaluationService create;
|
||||
|
||||
public eva_adjust_postponement_normalService(IBaseRepository2<eva_adjust_postponementEntity, int> repository, IMyDatabase mydb,
|
||||
Iexternal_linkageService inext,
|
||||
Iexternal_employeeService inemp,
|
||||
Ieva_create_evaluationService increate)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
emp = inemp;
|
||||
create = increate;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_adjust_postponementEntity GetEntity(eva_adjust_postponement_normalInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_adjust_postponementEntity>(model);
|
||||
}
|
||||
private List<eva_adjust_postponementEntity> GetEntityList(List<eva_adjust_postponement_normalInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_adjust_postponementEntity>>(models);
|
||||
}
|
||||
private eva_adjust_postponement_normalViewModel GetDto(eva_adjust_postponementEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_adjust_postponement_normalViewModel>(entity);
|
||||
}
|
||||
private List<eva_adjust_postponement_normalViewModel> GetDtoList(List<eva_adjust_postponementEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_adjust_postponement_normalViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_adjust_postponement_normalViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_adjust_postponement_normalWithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_adjust_postponement_normalWithSelectionViewModel>(entity);
|
||||
i.item_create_evaluation_id = create.GetListBySearch(new eva_create_evaluationSearchModel());
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
i.item_managed_by = all_emp.ToList();
|
||||
i.item_org_id = (from x in ext.GetDepartmentData() select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_adjust_postponement_normalWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_adjust_postponement_normalWithSelectionViewModel();
|
||||
i.item_create_evaluation_id = create.GetListBySearch(new eva_create_evaluationSearchModel());
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
i.item_managed_by = all_emp.ToList();
|
||||
i.item_org_id = (from x in ext.GetDepartmentData() select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_adjust_postponement_normalViewModel> GetListByfiscal_year(int? fiscal_year)
|
||||
{
|
||||
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)
|
||||
{
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
var dep = ext.GetDepartmentData();
|
||||
|
||||
var data = (
|
||||
from m_eva_adjust_postponement_normal in _repository.Context.eva_adjust_postponement
|
||||
|
||||
join fk_eva_create_evaluation4 in _repository.Context.eva_create_evaluation on m_eva_adjust_postponement_normal.create_evaluation_id equals fk_eva_create_evaluation4.id
|
||||
into eva_create_evaluationResult4
|
||||
from fk_eva_create_evaluationResult4 in eva_create_evaluationResult4.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage9 in all_emp on m_eva_adjust_postponement_normal.managed_by equals fk_external_linkage9.id
|
||||
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_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
|
||||
from fk_eva_performance_planResult1 in eva_performance_planResult1.DefaultIfEmpty()
|
||||
|
||||
join fk_eva_evaluation_group5 in _repository.Context.eva_evaluation_group on fk_eva_create_evaluationResult4.evaluation_group_id equals fk_eva_evaluation_group5.id
|
||||
into eva_evaluation_groupResult5
|
||||
from fk_eva_evaluation_groupResult5 in eva_evaluation_groupResult5.DefaultIfEmpty()
|
||||
|
||||
where 1==1
|
||||
//&& (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)
|
||||
&& (m_eva_adjust_postponement_normal.theRound == model.theRound || !model.theRound.HasValue)
|
||||
//&& (m_eva_adjust_postponement_normal.org_id == model.org_id || !model.org_id.HasValue)
|
||||
&& m_eva_adjust_postponement_normal.create_evaluation_id.HasValue
|
||||
|
||||
orderby m_eva_adjust_postponement_normal.created descending
|
||||
select new eva_adjust_postponement_normalViewModel()
|
||||
{
|
||||
id = m_eva_adjust_postponement_normal.id,
|
||||
fiscal_year = m_eva_adjust_postponement_normal.fiscal_year,
|
||||
theDate = m_eva_adjust_postponement_normal.theDate,
|
||||
theRound = m_eva_adjust_postponement_normal.theRound,
|
||||
create_evaluation_id = m_eva_adjust_postponement_normal.create_evaluation_id,
|
||||
limit = m_eva_adjust_postponement_normal.limit,
|
||||
limit_frame = m_eva_adjust_postponement_normal.limit_frame,
|
||||
limit_quota = m_eva_adjust_postponement_normal.limit_quota,
|
||||
percentage = m_eva_adjust_postponement_normal.percentage,
|
||||
managed_by = m_eva_adjust_postponement_normal.managed_by,
|
||||
//org_id = m_eva_adjust_postponement_normal.org_id,
|
||||
|
||||
create_evaluation_id_eva_create_evaluation_performance_plan_id = fk_eva_create_evaluationResult4.performance_plan_id,
|
||||
managed_by_external_linkage_external_name = fk_external_linkageResult9.fullname,
|
||||
//org_id_external_linkage_external_name = fk_external_linkageResult10.external_name,
|
||||
create_evaluation_id_description = fk_eva_evaluation_groupResult5.thegroup + " ปี " + fk_eva_performance_planResult1.fiscal_year.ToString(),
|
||||
|
||||
isActive = m_eva_adjust_postponement_normal.isActive,
|
||||
Created = m_eva_adjust_postponement_normal.created,
|
||||
Updated = m_eva_adjust_postponement_normal.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
public int GetNewPrimaryKey()
|
||||
{
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_adjust_postponement
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if(x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
|
||||
return newkey.Value;
|
||||
}
|
||||
|
||||
public eva_adjust_postponement_normalViewModel Insert(eva_adjust_postponement_normalInputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_adjust_postponement_normalViewModel Update(int id, eva_adjust_postponement_normalInputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.fiscal_year = model.fiscal_year;
|
||||
existingEntity.theDate = model.theDate;
|
||||
existingEntity.theRound = model.theRound;
|
||||
existingEntity.create_evaluation_id = model.create_evaluation_id;
|
||||
existingEntity.limit = model.limit;
|
||||
existingEntity.limit_frame = model.limit_frame;
|
||||
existingEntity.limit_quota = model.limit_quota;
|
||||
existingEntity.percentage = model.percentage;
|
||||
existingEntity.managed_by = model.managed_by;
|
||||
//existingEntity.org_id = model.org_id;
|
||||
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_adjust_postponement_normalInputModel> 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;
|
||||
|
||||
|
||||
_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_adjust_postponement_normalViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_adjust_postponement_normalViewModel 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,45 @@
|
||||
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_adjust_postponement_normalViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? fiscal_year { get; set; }
|
||||
|
||||
public DateTime? theDate { get; set; }
|
||||
|
||||
public string txt_theDate { get { return MyHelper.GetDateStringForReport(this.theDate); } }
|
||||
|
||||
public int? theRound { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public decimal? limit { get; set; }
|
||||
|
||||
public decimal? limit_frame { get; set; }
|
||||
|
||||
public decimal? limit_quota { get; set; }
|
||||
|
||||
public decimal? percentage { get; set; }
|
||||
|
||||
public int? managed_by { get; set; }
|
||||
|
||||
public int? org_id { get; set; }
|
||||
|
||||
public Guid? create_evaluation_id_eva_create_evaluation_performance_plan_id { get; set; }
|
||||
public string managed_by_external_linkage_external_name { get; set; }
|
||||
public string org_id_external_linkage_external_name { get; set; }
|
||||
|
||||
public string create_evaluation_id_description { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_adjust_postponement_normalWithSelectionViewModel: eva_adjust_postponement_normalViewModel
|
||||
{
|
||||
public List<eva_create_evaluationViewModel> item_create_evaluation_id { get; set; }
|
||||
public List<external_employeeViewModel> item_managed_by { get; set; }
|
||||
public List<external_linkageViewModel> item_org_id { 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_adjust_postponement_quotaService : IBaseService<int, eva_adjust_postponement_quotaInputModel, eva_adjust_postponement_quotaViewModel>
|
||||
{
|
||||
new eva_adjust_postponement_quotaViewModel Insert(eva_adjust_postponement_quotaInputModel model);
|
||||
new eva_adjust_postponement_quotaViewModel Update(int id, eva_adjust_postponement_quotaInputModel model);
|
||||
List<eva_adjust_postponement_quotaViewModel> GetListByfiscal_year(int? fiscal_year);
|
||||
List<eva_adjust_postponement_quotaViewModel> GetListBySearch(eva_adjust_postponement_quotaSearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_adjust_postponement_quotaInputModel> model);
|
||||
eva_adjust_postponement_quotaWithSelectionViewModel GetWithSelection(int id);
|
||||
eva_adjust_postponement_quotaWithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
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_adjust_postponement_quotaInputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? fiscal_year { get; set; }
|
||||
|
||||
public DateTime? theDate { get; set; }
|
||||
|
||||
public int? theRound { get; set; }
|
||||
|
||||
public decimal? limit_quota { get; set; }
|
||||
|
||||
public decimal? limit_frame_quota { get; set; }
|
||||
|
||||
public string command_no { get; set; }
|
||||
|
||||
public int? managed_by { 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_adjust_postponement_quotaReportRequestModel : eva_adjust_postponement_quotaSearchModel
|
||||
{
|
||||
public string filetype { get; set; }
|
||||
|
||||
public string contentType { get { return MyHelper.GetContentType(filetype); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
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_adjust_postponement_quotaSearchModel
|
||||
{
|
||||
|
||||
public int id { get; set; }
|
||||
|
||||
public int? fiscal_year { get; set; }
|
||||
|
||||
public int? theRound { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,250 @@
|
||||
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_adjust_postponement_quotaService : Ieva_adjust_postponement_quotaService
|
||||
{
|
||||
private IBaseRepository2<eva_adjust_postponementEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
|
||||
public eva_adjust_postponement_quotaService(IBaseRepository2<eva_adjust_postponementEntity, int> repository, IMyDatabase mydb,
|
||||
Iexternal_linkageService inext, Iexternal_employeeService inemp)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
emp = inemp;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_adjust_postponementEntity GetEntity(eva_adjust_postponement_quotaInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_adjust_postponementEntity>(model);
|
||||
}
|
||||
private List<eva_adjust_postponementEntity> GetEntityList(List<eva_adjust_postponement_quotaInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_adjust_postponementEntity>>(models);
|
||||
}
|
||||
private eva_adjust_postponement_quotaViewModel GetDto(eva_adjust_postponementEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_adjust_postponement_quotaViewModel>(entity);
|
||||
}
|
||||
private List<eva_adjust_postponement_quotaViewModel> GetDtoList(List<eva_adjust_postponementEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_adjust_postponement_quotaViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_adjust_postponement_quotaViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_adjust_postponement_quotaWithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_adjust_postponement_quotaWithSelectionViewModel>(entity);
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
i.item_managed_by = all_emp.ToList();
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_adjust_postponement_quotaWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_adjust_postponement_quotaWithSelectionViewModel();
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
i.item_managed_by = all_emp.ToList();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_adjust_postponement_quotaViewModel> GetListByfiscal_year(int? fiscal_year)
|
||||
{
|
||||
var model = new eva_adjust_postponement_quotaSearchModel();
|
||||
model.fiscal_year = fiscal_year;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_adjust_postponement_quotaViewModel> GetListBySearch(eva_adjust_postponement_quotaSearchModel model)
|
||||
{
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
var data = (
|
||||
from m_eva_adjust_postponement_quota in _repository.Context.eva_adjust_postponement
|
||||
|
||||
join fk_external_linkage7 in all_emp on m_eva_adjust_postponement_quota.managed_by equals fk_external_linkage7.id
|
||||
into external_linkageResult7
|
||||
from fk_external_linkageResult7 in external_linkageResult7.DefaultIfEmpty()
|
||||
|
||||
where 1==1
|
||||
//&& (m_eva_adjust_postponement_quota.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_adjust_postponement_quota.fiscal_year == model.fiscal_year || !model.fiscal_year.HasValue)
|
||||
&& (m_eva_adjust_postponement_quota.theRound == model.theRound || !model.theRound.HasValue)
|
||||
&& !m_eva_adjust_postponement_quota.create_evaluation_id.HasValue
|
||||
|
||||
orderby m_eva_adjust_postponement_quota.created descending
|
||||
select new eva_adjust_postponement_quotaViewModel()
|
||||
{
|
||||
id = m_eva_adjust_postponement_quota.id,
|
||||
fiscal_year = m_eva_adjust_postponement_quota.fiscal_year,
|
||||
theDate = m_eva_adjust_postponement_quota.theDate,
|
||||
theRound = m_eva_adjust_postponement_quota.theRound,
|
||||
limit_quota = m_eva_adjust_postponement_quota.limit_quota,
|
||||
limit_frame_quota = m_eva_adjust_postponement_quota.limit_frame_quota,
|
||||
command_no = m_eva_adjust_postponement_quota.command_no,
|
||||
managed_by = m_eva_adjust_postponement_quota.managed_by,
|
||||
|
||||
managed_by_external_linkage_external_name = fk_external_linkageResult7.fullname,
|
||||
|
||||
isActive = m_eva_adjust_postponement_quota.isActive,
|
||||
Created = m_eva_adjust_postponement_quota.created,
|
||||
Updated = m_eva_adjust_postponement_quota.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
public int GetNewPrimaryKey()
|
||||
{
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_adjust_postponement
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if(x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
|
||||
return newkey.Value;
|
||||
}
|
||||
|
||||
public eva_adjust_postponement_quotaViewModel Insert(eva_adjust_postponement_quotaInputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_adjust_postponement_quotaViewModel Update(int id, eva_adjust_postponement_quotaInputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.fiscal_year = model.fiscal_year;
|
||||
existingEntity.theDate = model.theDate;
|
||||
existingEntity.theRound = model.theRound;
|
||||
existingEntity.limit_quota = model.limit_quota;
|
||||
existingEntity.limit_frame_quota = model.limit_frame_quota;
|
||||
existingEntity.command_no = model.command_no;
|
||||
existingEntity.managed_by = model.managed_by;
|
||||
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_adjust_postponement_quotaInputModel> 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.limit_quota = i.limit_quota;
|
||||
existingEntity.limit_frame_quota = i.limit_frame_quota;
|
||||
existingEntity.command_no = i.command_no;
|
||||
existingEntity.managed_by = i.managed_by;
|
||||
|
||||
|
||||
_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_adjust_postponement_quotaViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_adjust_postponement_quotaViewModel 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,36 @@
|
||||
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_adjust_postponement_quotaViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? fiscal_year { get; set; }
|
||||
|
||||
public DateTime? theDate { get; set; }
|
||||
|
||||
public string txt_theDate { get { return MyHelper.GetDateStringForReport(this.theDate); } }
|
||||
|
||||
public int? theRound { get; set; }
|
||||
|
||||
public decimal? limit_quota { get; set; }
|
||||
|
||||
public decimal? limit_frame_quota { get; set; }
|
||||
|
||||
public string command_no { get; set; }
|
||||
|
||||
public int? managed_by { get; set; }
|
||||
|
||||
public string managed_by_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_adjust_postponement_quotaWithSelectionViewModel: eva_adjust_postponement_quotaViewModel
|
||||
{
|
||||
public List<external_employeeViewModel> item_managed_by { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
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_evaluationService : IBaseService<int, eva_create_evaluationInputModel, eva_create_evaluationViewModel>
|
||||
{
|
||||
new eva_create_evaluationViewModel Insert(eva_create_evaluationInputModel model);
|
||||
new eva_create_evaluationViewModel Update(int id, eva_create_evaluationInputModel model);
|
||||
List<eva_create_evaluationViewModel> GetListByperformance_plan_id(Guid? performance_plan_id);
|
||||
List<eva_create_evaluationViewModel> GetListBySearch(eva_create_evaluationSearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_create_evaluationInputModel> model);
|
||||
eva_create_evaluationWithSelectionViewModel GetWithSelection(int id);
|
||||
eva_create_evaluationWithSelectionViewModel GetBlankItem();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
33
Models/eva_create_evaluation/eva_create_evaluationEntity.cs
Normal file
33
Models/eva_create_evaluation/eva_create_evaluationEntity.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
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_evaluationEntity : BaseEntity2<int>
|
||||
{
|
||||
[ForeignKey("performance_plan_id")]
|
||||
public eva_performance_planEntity eva_performance_plan { get; set; }
|
||||
public Guid? performance_plan_id { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public decimal? score1 { get; set; }
|
||||
|
||||
public decimal? score2 { get; set; }
|
||||
|
||||
[ForeignKey("evaluation_group_id")]
|
||||
public eva_evaluation_groupEntity eva_evaluation_group { get; set; }
|
||||
public Guid? evaluation_group_id { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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_evaluationInputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public Guid? performance_plan_id { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public decimal? score1 { get; set; }
|
||||
|
||||
public decimal? score2 { get; set; }
|
||||
|
||||
public Guid? evaluation_group_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_evaluationReportRequestModel : eva_create_evaluationSearchModel
|
||||
{
|
||||
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_evaluationSearchModel
|
||||
{
|
||||
|
||||
public Guid? performance_plan_id { get; set; }
|
||||
|
||||
public Guid? evaluation_group_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
257
Models/eva_create_evaluation/eva_create_evaluationService.cs
Normal file
257
Models/eva_create_evaluation/eva_create_evaluationService.cs
Normal file
@@ -0,0 +1,257 @@
|
||||
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_evaluationService : Ieva_create_evaluationService
|
||||
{
|
||||
private IBaseRepository2<eva_create_evaluationEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
Iexternal_employeeService emp;
|
||||
|
||||
public eva_create_evaluationService(IBaseRepository2<eva_create_evaluationEntity, int> repository, IMyDatabase mydb,
|
||||
Iexternal_linkageService inext, Iexternal_employeeService inemp)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
emp = inemp;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_create_evaluationEntity GetEntity(eva_create_evaluationInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluationEntity>(model);
|
||||
}
|
||||
private List<eva_create_evaluationEntity> GetEntityList(List<eva_create_evaluationInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluationEntity>>(models);
|
||||
}
|
||||
private eva_create_evaluationViewModel GetDto(eva_create_evaluationEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluationViewModel>(entity);
|
||||
}
|
||||
private List<eva_create_evaluationViewModel> GetDtoList(List<eva_create_evaluationEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluationViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_create_evaluationViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_create_evaluationWithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
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_evaluation_group_id = (from x in _repository.Context.eva_evaluation_group select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_create_evaluationWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
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_evaluation_group_id = (from x in _repository.Context.eva_evaluation_group select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_create_evaluationViewModel> GetListByperformance_plan_id(Guid? performance_plan_id)
|
||||
{
|
||||
var model = new eva_create_evaluationSearchModel();
|
||||
model.performance_plan_id = performance_plan_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_create_evaluationViewModel> GetListBySearch(eva_create_evaluationSearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_create_evaluation in _repository.Context.eva_create_evaluation
|
||||
|
||||
join fk_eva_performance_plan1 in _repository.Context.eva_performance_plan on m_eva_create_evaluation.performance_plan_id equals fk_eva_performance_plan1.id
|
||||
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
|
||||
into external_linkageResult2
|
||||
from fk_external_linkageResult2 in external_linkageResult2.DefaultIfEmpty()
|
||||
|
||||
join fk_eva_evaluation_group5 in _repository.Context.eva_evaluation_group on m_eva_create_evaluation.evaluation_group_id equals fk_eva_evaluation_group5.id
|
||||
into eva_evaluation_groupResult5
|
||||
from fk_eva_evaluation_groupResult5 in eva_evaluation_groupResult5.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)
|
||||
|
||||
|
||||
orderby m_eva_create_evaluation.created descending
|
||||
select new eva_create_evaluationViewModel()
|
||||
{
|
||||
id = m_eva_create_evaluation.id,
|
||||
performance_plan_id = m_eva_create_evaluation.performance_plan_id,
|
||||
employee_id = m_eva_create_evaluation.employee_id,
|
||||
score1 = m_eva_create_evaluation.score1,
|
||||
score2 = m_eva_create_evaluation.score2,
|
||||
evaluation_group_id = m_eva_create_evaluation.evaluation_group_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,
|
||||
|
||||
isActive = m_eva_create_evaluation.isActive,
|
||||
Created = m_eva_create_evaluation.created,
|
||||
Updated = m_eva_create_evaluation.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
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if(x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
|
||||
return newkey.Value;
|
||||
}
|
||||
|
||||
public eva_create_evaluationViewModel Insert(eva_create_evaluationInputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_create_evaluationViewModel Update(int id, eva_create_evaluationInputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.performance_plan_id = model.performance_plan_id;
|
||||
existingEntity.employee_id = model.employee_id;
|
||||
existingEntity.score1 = model.score1;
|
||||
existingEntity.score2 = model.score2;
|
||||
existingEntity.evaluation_group_id = model.evaluation_group_id;
|
||||
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_create_evaluationInputModel> 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.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;
|
||||
|
||||
|
||||
_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_evaluationViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_create_evaluationViewModel 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,43 @@
|
||||
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_evaluationViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public Guid? performance_plan_id { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public decimal? score1 { get; set; }
|
||||
|
||||
public decimal? score2 { get; set; }
|
||||
|
||||
public Guid? evaluation_group_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 description
|
||||
{
|
||||
get
|
||||
{
|
||||
string y = "";
|
||||
|
||||
if (performance_plan_id_eva_performance_plan_fiscal_year.HasValue) y = performance_plan_id_eva_performance_plan_fiscal_year.ToString();
|
||||
|
||||
return evaluation_group_id_eva_evaluation_group_code + " ปี " +y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_create_evaluationWithSelectionViewModel: eva_create_evaluationViewModel
|
||||
{
|
||||
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; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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_detailService : IBaseService<int, eva_create_evaluation_detailInputModel, eva_create_evaluation_detailViewModel>
|
||||
{
|
||||
new eva_create_evaluation_detailViewModel Insert(eva_create_evaluation_detailInputModel model);
|
||||
new eva_create_evaluation_detailViewModel Update(int id, eva_create_evaluation_detailInputModel model);
|
||||
List<eva_create_evaluation_detailViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id);
|
||||
List<eva_create_evaluation_detailViewModel> GetListBySearch(eva_create_evaluation_detailSearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_create_evaluation_detailInputModel> model);
|
||||
string AddMultiple(int? create_evaluation_id, List<int> model);
|
||||
eva_create_evaluation_detailWithSelectionViewModel GetWithSelection(int id);
|
||||
eva_create_evaluation_detailWithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
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_detailEntity : BaseEntity2<int>
|
||||
{
|
||||
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public int? chief { get; set; }
|
||||
|
||||
public decimal? total_summary_chief { get; set; }
|
||||
|
||||
public decimal? Final_summary_chief { get; set; }
|
||||
|
||||
public decimal? total_summary_supervisor { get; set; }
|
||||
|
||||
public decimal? Final_summary_supervisor { get; set; }
|
||||
|
||||
public decimal? total_summary_competency_chief { get; set; }
|
||||
|
||||
public decimal? Final_summary_competency_chief { get; set; }
|
||||
|
||||
public decimal? total_summary_competency_supervisor { get; set; }
|
||||
|
||||
public decimal? Final_summary_competency_supervisor { get; set; }
|
||||
|
||||
public decimal? achievement_chief { get; set; }
|
||||
|
||||
public decimal? competency_chief { get; set; }
|
||||
|
||||
public decimal? score_chief { get; set; }
|
||||
|
||||
[MaxLength(255)]
|
||||
public string level_score_chief { get; set; }
|
||||
|
||||
public decimal? achievement_supervisor { get; set; }
|
||||
|
||||
public decimal? competency_supervisor { get; set; }
|
||||
|
||||
public decimal? score_supervisor { get; set; }
|
||||
|
||||
[MaxLength(255)]
|
||||
public string level_score_supervisor { get; set; }
|
||||
|
||||
public int? supervisor1 { get; set; }
|
||||
|
||||
[MaxLength(1)]
|
||||
public string supervisor1_result { get; set; }
|
||||
|
||||
[MaxLength(1000)]
|
||||
public string supervisor1_remark { get; set; }
|
||||
|
||||
public DateTime? supervisor1_date { get; set; }
|
||||
|
||||
public int? supervisor2 { get; set; }
|
||||
|
||||
[MaxLength(1)]
|
||||
public string supervisor2_result { get; set; }
|
||||
|
||||
[MaxLength(1000)]
|
||||
public string supervisor2_remark { get; set; }
|
||||
|
||||
public DateTime? supervisor2_date { get; set; }
|
||||
|
||||
[MaxLength(1)]
|
||||
public string status_self { get; set; }
|
||||
|
||||
[MaxLength(1)]
|
||||
public string status_chief { get; set; }
|
||||
|
||||
[MaxLength(1)]
|
||||
public string status_supervisor { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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_detailInputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public int? chief { 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_detailReportRequestModel : eva_create_evaluation_detailSearchModel
|
||||
{
|
||||
public string filetype { get; set; }
|
||||
|
||||
public string contentType { get { return MyHelper.GetContentType(filetype); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_detailSearchModel
|
||||
{
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,390 @@
|
||||
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_detailService : Ieva_create_evaluation_detailService
|
||||
{
|
||||
private IBaseRepository2<eva_create_evaluation_detailEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
private Iexternal_competencyService com;
|
||||
|
||||
public eva_create_evaluation_detailService(IBaseRepository2<eva_create_evaluation_detailEntity, int> repository,
|
||||
IMyDatabase mydb, Iexternal_linkageService inext, Iexternal_employeeService inemp,
|
||||
Iexternal_competencyService incom)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
emp = inemp;
|
||||
com = incom;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_create_evaluation_detailEntity GetEntity(eva_create_evaluation_detailInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detailEntity>(model);
|
||||
}
|
||||
private List<eva_create_evaluation_detailEntity> GetEntityList(List<eva_create_evaluation_detailInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detailEntity>>(models);
|
||||
}
|
||||
private eva_create_evaluation_detailViewModel GetDto(eva_create_evaluation_detailEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detailViewModel>(entity);
|
||||
}
|
||||
private List<eva_create_evaluation_detailViewModel> GetDtoList(List<eva_create_evaluation_detailEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detailViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_create_evaluation_detailViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_create_evaluation_detailWithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_create_evaluation_detailWithSelectionViewModel>(entity);
|
||||
i.item_employee_id = emp.GetListByemployee_type(null, null);
|
||||
i.item_chief = i.item_employee_id;
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_create_evaluation_detailWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_create_evaluation_detailWithSelectionViewModel();
|
||||
i.item_employee_id = emp.GetListByemployee_type(null, null);
|
||||
i.item_chief = i.item_employee_id;
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detailViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id)
|
||||
{
|
||||
var model = new eva_create_evaluation_detailSearchModel();
|
||||
model.create_evaluation_id = create_evaluation_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detailViewModel> GetListBySearch(eva_create_evaluation_detailSearchModel model)
|
||||
{
|
||||
var allemp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
var data = (
|
||||
from m_eva_create_evaluation_detail in _repository.Context.eva_create_evaluation_detail
|
||||
|
||||
join fk_external_linkage2 in allemp on m_eva_create_evaluation_detail.employee_id equals fk_external_linkage2.id
|
||||
into external_linkageResult2
|
||||
from fk_external_linkageResult2 in external_linkageResult2.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage3 in allemp on m_eva_create_evaluation_detail.chief equals fk_external_linkage3.id
|
||||
into external_linkageResult3
|
||||
from fk_external_linkageResult3 in external_linkageResult3.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage21 in ext.GetAgreeDisagree() on m_eva_create_evaluation_detail.supervisor1_result equals fk_external_linkage21.external_code
|
||||
into external_linkageResult21
|
||||
from fk_external_linkageResult21 in external_linkageResult21.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage25 in ext.GetAgreeDisagree() on m_eva_create_evaluation_detail.supervisor2_result equals fk_external_linkage25.external_code
|
||||
into external_linkageResult25
|
||||
from fk_external_linkageResult25 in external_linkageResult25.DefaultIfEmpty()
|
||||
|
||||
|
||||
where 1 ==1
|
||||
&& (m_eva_create_evaluation_detail.create_evaluation_id == model.create_evaluation_id || !model.create_evaluation_id.HasValue)
|
||||
|
||||
orderby m_eva_create_evaluation_detail.created descending
|
||||
select new eva_create_evaluation_detailViewModel()
|
||||
{
|
||||
id = m_eva_create_evaluation_detail.id,
|
||||
create_evaluation_id = m_eva_create_evaluation_detail.create_evaluation_id,
|
||||
employee_id = m_eva_create_evaluation_detail.employee_id,
|
||||
chief = m_eva_create_evaluation_detail.chief,
|
||||
total_summary_chief = m_eva_create_evaluation_detail.total_summary_chief,
|
||||
Final_summary_chief = m_eva_create_evaluation_detail.Final_summary_chief,
|
||||
total_summary_supervisor = m_eva_create_evaluation_detail.total_summary_supervisor,
|
||||
Final_summary_supervisor = m_eva_create_evaluation_detail.Final_summary_supervisor,
|
||||
total_summary_competency_chief = m_eva_create_evaluation_detail.total_summary_competency_chief,
|
||||
Final_summary_competency_chief = m_eva_create_evaluation_detail.Final_summary_competency_chief,
|
||||
total_summary_competency_supervisor = m_eva_create_evaluation_detail.total_summary_competency_supervisor,
|
||||
Final_summary_competency_supervisor = m_eva_create_evaluation_detail.Final_summary_competency_supervisor,
|
||||
achievement_chief = m_eva_create_evaluation_detail.achievement_chief,
|
||||
competency_chief = m_eva_create_evaluation_detail.competency_chief,
|
||||
score_chief = m_eva_create_evaluation_detail.score_chief,
|
||||
level_score_chief = m_eva_create_evaluation_detail.level_score_chief,
|
||||
achievement_supervisor = m_eva_create_evaluation_detail.achievement_supervisor,
|
||||
competency_supervisor = m_eva_create_evaluation_detail.competency_supervisor,
|
||||
score_supervisor = m_eva_create_evaluation_detail.score_supervisor,
|
||||
level_score_supervisor = m_eva_create_evaluation_detail.level_score_supervisor,
|
||||
supervisor1 = m_eva_create_evaluation_detail.supervisor1,
|
||||
supervisor1_result = m_eva_create_evaluation_detail.supervisor1_result,
|
||||
supervisor1_remark = m_eva_create_evaluation_detail.supervisor1_remark,
|
||||
supervisor1_date = m_eva_create_evaluation_detail.supervisor1_date,
|
||||
supervisor2 = m_eva_create_evaluation_detail.supervisor2,
|
||||
supervisor2_result = m_eva_create_evaluation_detail.supervisor2_result,
|
||||
supervisor2_remark = m_eva_create_evaluation_detail.supervisor2_remark,
|
||||
supervisor2_date = m_eva_create_evaluation_detail.supervisor2_date,
|
||||
status_self = m_eva_create_evaluation_detail.status_self,
|
||||
status_chief = m_eva_create_evaluation_detail.status_chief,
|
||||
status_supervisor = m_eva_create_evaluation_detail.status_supervisor,
|
||||
|
||||
employee_id_external_linkage_external_name = fk_external_linkageResult2.fullname,
|
||||
chief_external_linkage_external_name = fk_external_linkageResult3.fullname,
|
||||
supervisor1_result_external_linkage_external_name = fk_external_linkageResult21.external_name,
|
||||
supervisor2_result_external_linkage_external_name = fk_external_linkageResult25.external_name,
|
||||
|
||||
isActive = m_eva_create_evaluation_detail.isActive,
|
||||
Created = m_eva_create_evaluation_detail.created,
|
||||
Updated = m_eva_create_evaluation_detail.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_detailViewModel Insert(eva_create_evaluation_detailInputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detailViewModel Update(int id, eva_create_evaluation_detailInputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.create_evaluation_id = model.create_evaluation_id;
|
||||
existingEntity.employee_id = model.employee_id;
|
||||
existingEntity.chief = model.chief;
|
||||
|
||||
|
||||
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_detailInputModel> 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.employee_id = i.employee_id;
|
||||
existingEntity.chief = i.chief;
|
||||
|
||||
|
||||
_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 int GetNewPrimaryKeyBehavior()
|
||||
{
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_evaluation_behavior
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if (x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
|
||||
return newkey.Value;
|
||||
}
|
||||
|
||||
public string AddMultiple(int? create_evaluation_id, List<int> model)
|
||||
{
|
||||
if (!create_evaluation_id.HasValue)
|
||||
{
|
||||
return "0";
|
||||
}
|
||||
else
|
||||
{
|
||||
int j = 0;
|
||||
int current_new_id = GetNewPrimaryKey();
|
||||
var allemp = emp.GetListByemployee_type(null, null);
|
||||
var comx = com.Getcom_competencys();
|
||||
var k1 = GetNewPrimaryKeyBehavior();
|
||||
|
||||
var ex = (from x in _repository.Context.eva_create_evaluation_detail
|
||||
where x.create_evaluation_id == create_evaluation_id
|
||||
select x.employee_id).ToList();
|
||||
|
||||
foreach (var i in model)
|
||||
{
|
||||
if (checkExistEmployeeInExternal(i, allemp))
|
||||
{
|
||||
if (!checkExistEmployeeInInternal(i, ex))
|
||||
{
|
||||
var n = new eva_create_evaluation_detailEntity();
|
||||
n.id = current_new_id;
|
||||
n.employee_id = i;
|
||||
n.create_evaluation_id = create_evaluation_id;
|
||||
n.chief = emp.GetLeader(i);
|
||||
n.created = DateTime.Now;
|
||||
n.updated = DateTime.Now;
|
||||
n.isActive = true;
|
||||
_repository.Context.eva_create_evaluation_detail.Add(n);
|
||||
|
||||
// ต้องเพิ่มการ add eva_evaluation_behavior โดยดึงจาก สมรรนะหลัก 5 ตัว
|
||||
foreach (var k in comx)
|
||||
{
|
||||
var p = new eva_evaluation_behaviorEntity();
|
||||
p.id = k1;
|
||||
p.create_evaluation_detail_id = n.id;
|
||||
p.behavior = k.competency_code + " " + k.competency_topic;
|
||||
p.weight = 0;
|
||||
p.created = DateTime.Now;
|
||||
p.updated = DateTime.Now;
|
||||
p.isActive = true;
|
||||
_repository.Context.eva_evaluation_behavior.Add(p);
|
||||
|
||||
k1++;
|
||||
}
|
||||
|
||||
j++;
|
||||
current_new_id++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_repository.Context.SaveChanges();
|
||||
return j.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private bool checkExistEmployeeInExternal(int emp_id, List<external_employeeViewModel> emp)
|
||||
{
|
||||
foreach (var i in emp)
|
||||
{
|
||||
if (i.id == emp_id) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool checkExistEmployeeInInternal(int emp_id, List<int?> emp)
|
||||
{
|
||||
foreach (var i in emp)
|
||||
{
|
||||
if (i.Value == emp_id) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detailViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_create_evaluation_detailViewModel SetAsInactive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsInActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public void Delete(int id)
|
||||
{
|
||||
var a1 = from i in _repository.Context.eva_evaluation_achievement
|
||||
where i.create_evaluation_detail_id == id
|
||||
select i;
|
||||
_repository.Context.eva_evaluation_achievement.RemoveRange(a1);
|
||||
|
||||
var a2 = from i in _repository.Context.eva_evaluation_behavior
|
||||
where i.create_evaluation_detail_id == id
|
||||
select i;
|
||||
_repository.Context.eva_evaluation_behavior.RemoveRange(a2);
|
||||
|
||||
_repository.Delete(id);
|
||||
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Match Item
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
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_detailViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? employee_id { get; set; }
|
||||
|
||||
public int? chief { get; set; }
|
||||
|
||||
public decimal? total_summary_chief { get; set; }
|
||||
|
||||
public decimal? Final_summary_chief { get; set; }
|
||||
|
||||
public decimal? total_summary_supervisor { get; set; }
|
||||
|
||||
public decimal? Final_summary_supervisor { get; set; }
|
||||
|
||||
public decimal? total_summary_competency_chief { get; set; }
|
||||
|
||||
public decimal? Final_summary_competency_chief { get; set; }
|
||||
|
||||
public decimal? total_summary_competency_supervisor { get; set; }
|
||||
|
||||
public decimal? Final_summary_competency_supervisor { get; set; }
|
||||
|
||||
public decimal? achievement_chief { get; set; }
|
||||
|
||||
public decimal? competency_chief { get; set; }
|
||||
|
||||
public decimal? score_chief { get; set; }
|
||||
|
||||
public string level_score_chief { get; set; }
|
||||
|
||||
public decimal? achievement_supervisor { get; set; }
|
||||
|
||||
public decimal? competency_supervisor { get; set; }
|
||||
|
||||
public decimal? score_supervisor { get; set; }
|
||||
|
||||
public string level_score_supervisor { get; set; }
|
||||
|
||||
public int? supervisor1 { get; set; }
|
||||
|
||||
public string supervisor1_result { get; set; }
|
||||
|
||||
public string supervisor1_remark { get; set; }
|
||||
|
||||
public DateTime? supervisor1_date { get; set; }
|
||||
|
||||
public string txt_supervisor1_date { get { return MyHelper.GetDateStringForReport(this.supervisor1_date); } }
|
||||
|
||||
public int? supervisor2 { get; set; }
|
||||
|
||||
public string supervisor2_result { get; set; }
|
||||
|
||||
public string supervisor2_remark { get; set; }
|
||||
|
||||
public DateTime? supervisor2_date { get; set; }
|
||||
|
||||
public string txt_supervisor2_date { get { return MyHelper.GetDateStringForReport(this.supervisor2_date); } }
|
||||
|
||||
public string status_self { get; set; }
|
||||
|
||||
public string status_chief { get; set; }
|
||||
|
||||
public string status_supervisor { get; set; }
|
||||
|
||||
public string employee_id_external_linkage_external_name { get; set; }
|
||||
public string chief_external_linkage_external_name { get; set; }
|
||||
public string supervisor1_result_external_linkage_external_name { get; set; }
|
||||
public string supervisor2_result_external_linkage_external_name { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_create_evaluation_detailWithSelectionViewModel: eva_create_evaluation_detailViewModel
|
||||
{
|
||||
public List<external_employeeViewModel> item_employee_id { get; set; }
|
||||
public List<external_employeeViewModel> item_chief { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
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_agreementService
|
||||
{
|
||||
List<eva_create_evaluation_detail_agreementViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id, int? emp_id);
|
||||
List<eva_create_evaluation_detail_agreementViewModel> GetListBySearch(eva_create_evaluation_detail_agreementSearchModel model, int? emp_id);
|
||||
|
||||
eva_create_evaluation_detail_agreementWithSelectionViewModel GetWithSelection(int id);
|
||||
eva_create_evaluation_detail_agreementWithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
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_agreementInputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public string evaluation_round { get; set; }
|
||||
|
||||
public string employee_code { get; set; }
|
||||
|
||||
public string employee_fullname { get; set; }
|
||||
|
||||
public string employee_position { get; set; }
|
||||
|
||||
public string employee_position_type { get; set; }
|
||||
|
||||
public string employee_position_level { get; set; }
|
||||
|
||||
public string employee_org { get; set; }
|
||||
|
||||
public string chief_fullname { get; set; }
|
||||
|
||||
public string chief_position { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? org_id { get; set; }
|
||||
|
||||
public string search_employee_code { get; set; }
|
||||
|
||||
public string search_employee_fullname { 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_agreementReportRequestModel : eva_create_evaluation_detail_agreementSearchModel
|
||||
{
|
||||
public string filetype { get; set; }
|
||||
|
||||
public string contentType { get { return MyHelper.GetContentType(filetype); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_create_evaluation_detail_agreementSearchModel
|
||||
{
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? org_id { get; set; }
|
||||
|
||||
public string search_employee_code { get; set; }
|
||||
|
||||
public string search_employee_fullname { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
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;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_create_evaluation_detail_agreementService : Ieva_create_evaluation_detail_agreementService
|
||||
{
|
||||
private IBaseRepository2<eva_create_evaluation_detailEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
|
||||
public eva_create_evaluation_detail_agreementService(IBaseRepository2<eva_create_evaluation_detailEntity, 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_detailEntity GetEntity(eva_create_evaluation_detail_agreementInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detailEntity>(model);
|
||||
}
|
||||
private List<eva_create_evaluation_detailEntity> GetEntityList(List<eva_create_evaluation_detail_agreementInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detailEntity>>(models);
|
||||
}
|
||||
private eva_create_evaluation_detail_agreementViewModel GetDto(eva_create_evaluation_detailEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detail_agreementViewModel>(entity);
|
||||
}
|
||||
private List<eva_create_evaluation_detail_agreementViewModel> GetDtoList(List<eva_create_evaluation_detailEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detail_agreementViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_create_evaluation_detail_agreementWithSelectionViewModel Get(int id)
|
||||
{
|
||||
var allemp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
var data = (
|
||||
from m_eva_create_evaluation_detail_agreement in _repository.Context.eva_create_evaluation_detail
|
||||
|
||||
join fk_external_employee in allemp on m_eva_create_evaluation_detail_agreement.employee_id equals fk_external_employee.id
|
||||
into external_employeeResult
|
||||
from fk_external_employee in external_employeeResult.DefaultIfEmpty()
|
||||
|
||||
join fk_external_chief in allemp on m_eva_create_evaluation_detail_agreement.chief equals fk_external_chief.id
|
||||
into external_chiefResult
|
||||
from fk_external_chief in external_chiefResult.DefaultIfEmpty()
|
||||
|
||||
join fk_eva_create_evaluation10 in _repository.Context.eva_create_evaluation on m_eva_create_evaluation_detail_agreement.create_evaluation_id equals fk_eva_create_evaluation10.id
|
||||
into eva_create_evaluationResult10
|
||||
from fk_eva_create_evaluationResult10 in eva_create_evaluationResult10.DefaultIfEmpty()
|
||||
|
||||
where m_eva_create_evaluation_detail_agreement.id == id
|
||||
|
||||
orderby m_eva_create_evaluation_detail_agreement.created descending
|
||||
select new eva_create_evaluation_detail_agreementWithSelectionViewModel()
|
||||
{
|
||||
id = m_eva_create_evaluation_detail_agreement.id,
|
||||
evaluation_round = fk_eva_create_evaluationResult10.eva_performance_plan.theTime.ToString(),
|
||||
employee_code = fk_external_employee.employee_no,
|
||||
employee_fullname = fk_external_employee.fullname,
|
||||
employee_position = fk_external_employee.position_name,
|
||||
employee_position_type = fk_external_employee.employee_type_name,
|
||||
employee_position_level = fk_external_employee.position_level_text,
|
||||
employee_org = fk_external_employee.department_name,
|
||||
chief_fullname = fk_external_chief.fullname,
|
||||
chief_position = fk_external_chief.position_name,
|
||||
create_evaluation_id = m_eva_create_evaluation_detail_agreement.create_evaluation_id,
|
||||
org_id = fk_external_employee.department_id,
|
||||
search_employee_code = fk_external_employee.employee_no,
|
||||
search_employee_fullname = fk_external_employee.fullname,
|
||||
status_self = m_eva_create_evaluation_detail_agreement.status_self,
|
||||
status_chief = m_eva_create_evaluation_detail_agreement.status_chief,
|
||||
status_supervisor = m_eva_create_evaluation_detail_agreement.status_supervisor,
|
||||
|
||||
org_id_external_linkage_external_name = fk_external_employee.department_name,
|
||||
|
||||
isActive = m_eva_create_evaluation_detail_agreement.isActive,
|
||||
Created = m_eva_create_evaluation_detail_agreement.created,
|
||||
Updated = m_eva_create_evaluation_detail_agreement.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data[0];
|
||||
}
|
||||
public eva_create_evaluation_detail_agreementWithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var item = Get(id);
|
||||
var i = item;
|
||||
i.item_org_id = ext.GetDepartmentData();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_create_evaluation_detail_agreementWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_create_evaluation_detail_agreementWithSelectionViewModel();
|
||||
i.item_org_id = ext.GetDepartmentData();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_agreementViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id, int? emp_id)
|
||||
{
|
||||
var model = new eva_create_evaluation_detail_agreementSearchModel();
|
||||
model.create_evaluation_id = create_evaluation_id;
|
||||
return GetListBySearch(model, emp_id);
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_agreementViewModel> GetListBySearch(eva_create_evaluation_detail_agreementSearchModel model, int? emp_id)
|
||||
{
|
||||
|
||||
var allemp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
var data = (
|
||||
from m_eva_create_evaluation_detail_agreement in _repository.Context.eva_create_evaluation_detail
|
||||
|
||||
join fk_external_employee in allemp on m_eva_create_evaluation_detail_agreement.employee_id equals fk_external_employee.id
|
||||
into external_employeeResult
|
||||
from fk_external_employee in external_employeeResult.DefaultIfEmpty()
|
||||
|
||||
join fk_external_chief in allemp on m_eva_create_evaluation_detail_agreement.chief equals fk_external_chief.id
|
||||
into external_chiefResult
|
||||
from fk_external_chief in external_chiefResult.DefaultIfEmpty()
|
||||
|
||||
join fk_eva_create_evaluation10 in _repository.Context.eva_create_evaluation on m_eva_create_evaluation_detail_agreement.create_evaluation_id equals fk_eva_create_evaluation10.id
|
||||
into eva_create_evaluationResult10
|
||||
from fk_eva_create_evaluationResult10 in eva_create_evaluationResult10.DefaultIfEmpty()
|
||||
|
||||
where 1==1
|
||||
&& (m_eva_create_evaluation_detail_agreement.create_evaluation_id == model.create_evaluation_id || !model.create_evaluation_id.HasValue)
|
||||
&& (fk_external_employee.department_id == model.org_id || !model.org_id.HasValue)
|
||||
&& (fk_external_employee.employee_no == model.search_employee_code || string.IsNullOrEmpty(model.search_employee_code))
|
||||
&& (fk_external_employee.fullname.Contains(model.search_employee_fullname) || string.IsNullOrEmpty(model.search_employee_fullname))
|
||||
&& m_eva_create_evaluation_detail_agreement.employee_id == emp_id
|
||||
|
||||
orderby m_eva_create_evaluation_detail_agreement.created descending
|
||||
select new eva_create_evaluation_detail_agreementViewModel()
|
||||
{
|
||||
id = m_eva_create_evaluation_detail_agreement.id,
|
||||
evaluation_round = fk_eva_create_evaluationResult10.eva_performance_plan.theTime.ToString(),
|
||||
employee_code = fk_external_employee.employee_no,
|
||||
employee_fullname = fk_external_employee.fullname,
|
||||
employee_position = fk_external_employee.position_name,
|
||||
employee_position_type = fk_external_employee.employee_type_name,
|
||||
employee_position_level = fk_external_employee.position_level_text,
|
||||
employee_org = fk_external_employee.department_name,
|
||||
chief_fullname = fk_external_chief.fullname,
|
||||
chief_position = fk_external_chief.position_name,
|
||||
create_evaluation_id = m_eva_create_evaluation_detail_agreement.create_evaluation_id,
|
||||
org_id = fk_external_employee.department_id,
|
||||
search_employee_code = fk_external_employee.employee_no,
|
||||
search_employee_fullname = fk_external_employee.fullname,
|
||||
status_self = m_eva_create_evaluation_detail_agreement.status_self,
|
||||
status_chief = m_eva_create_evaluation_detail_agreement.status_chief,
|
||||
status_supervisor = m_eva_create_evaluation_detail_agreement.status_supervisor,
|
||||
|
||||
org_id_external_linkage_external_name = fk_external_employee.department_name,
|
||||
|
||||
isActive = m_eva_create_evaluation_detail_agreement.isActive,
|
||||
Created = m_eva_create_evaluation_detail_agreement.created,
|
||||
Updated = m_eva_create_evaluation_detail_agreement.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
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_agreementViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public string evaluation_round { get; set; }
|
||||
|
||||
public string employee_code { get; set; }
|
||||
|
||||
public string employee_fullname { get; set; }
|
||||
|
||||
public string employee_position { get; set; }
|
||||
|
||||
public string employee_position_type { get; set; }
|
||||
|
||||
public string employee_position_level { get; set; }
|
||||
|
||||
public string employee_org { get; set; }
|
||||
|
||||
public string chief_fullname { get; set; }
|
||||
|
||||
public string chief_position { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? org_id { get; set; }
|
||||
|
||||
public string search_employee_code { get; set; }
|
||||
|
||||
public string search_employee_fullname { get; set; }
|
||||
|
||||
public string org_id_external_linkage_external_name { get; set; }
|
||||
|
||||
public string status_self { get; set; }
|
||||
|
||||
public string status_chief { get; set; }
|
||||
|
||||
public string status_supervisor { 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_agreementWithSelectionViewModel: eva_create_evaluation_detail_agreementViewModel
|
||||
{
|
||||
public List<external_linkageViewModel> item_org_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
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_processService
|
||||
{
|
||||
List<eva_create_evaluation_detail_processViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id);
|
||||
List<eva_create_evaluation_detail_processViewModel> GetListBySearch(eva_create_evaluation_detail_processSearchModel model);
|
||||
|
||||
eva_create_evaluation_detail_processWithSelectionViewModel GetWithSelection(int id);
|
||||
eva_create_evaluation_detail_processWithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
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_processInputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public string evaluation_round { get; set; }
|
||||
|
||||
public string employee_code { get; set; }
|
||||
|
||||
public string employee_fullname { get; set; }
|
||||
|
||||
public string employee_position { get; set; }
|
||||
|
||||
public string employee_position_type { get; set; }
|
||||
|
||||
public string employee_position_level { get; set; }
|
||||
|
||||
public string employee_org { get; set; }
|
||||
|
||||
public string chief_fullname { get; set; }
|
||||
|
||||
public string chief_position { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? org_id { get; set; }
|
||||
|
||||
public string search_employee_code { get; set; }
|
||||
|
||||
public string search_employee_fullname { 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_processReportRequestModel : eva_create_evaluation_detail_processSearchModel
|
||||
{
|
||||
public string filetype { get; set; }
|
||||
|
||||
public string contentType { get { return MyHelper.GetContentType(filetype); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_create_evaluation_detail_processSearchModel
|
||||
{
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? org_id { get; set; }
|
||||
|
||||
public string search_employee_code { get; set; }
|
||||
|
||||
public string search_employee_fullname { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
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_processService : Ieva_create_evaluation_detail_processService
|
||||
{
|
||||
private IBaseRepository2<eva_create_evaluation_detailEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
Iexternal_employeeService emp;
|
||||
|
||||
public eva_create_evaluation_detail_processService(IBaseRepository2<eva_create_evaluation_detailEntity, 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_detailEntity GetEntity(eva_create_evaluation_detail_processInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detailEntity>(model);
|
||||
}
|
||||
private List<eva_create_evaluation_detailEntity> GetEntityList(List<eva_create_evaluation_detail_processInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detailEntity>>(models);
|
||||
}
|
||||
private eva_create_evaluation_detail_processViewModel GetDto(eva_create_evaluation_detailEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detail_processViewModel>(entity);
|
||||
}
|
||||
private List<eva_create_evaluation_detail_processViewModel> GetDtoList(List<eva_create_evaluation_detailEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detail_processViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_create_evaluation_detail_processWithSelectionViewModel Get(int id)
|
||||
{
|
||||
var allemp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
var data = (
|
||||
from m_eva_create_evaluation_detail_process in _repository.Context.eva_create_evaluation_detail
|
||||
|
||||
join fk_external_employee in allemp on m_eva_create_evaluation_detail_process.employee_id equals fk_external_employee.id
|
||||
into external_employeeResult
|
||||
from fk_external_employee in external_employeeResult.DefaultIfEmpty()
|
||||
|
||||
join fk_external_chief in allemp on m_eva_create_evaluation_detail_process.chief equals fk_external_chief.id
|
||||
into external_chiefResult
|
||||
from fk_external_chief in external_chiefResult.DefaultIfEmpty()
|
||||
|
||||
join fk_eva_create_evaluation10 in _repository.Context.eva_create_evaluation on m_eva_create_evaluation_detail_process.create_evaluation_id equals fk_eva_create_evaluation10.id
|
||||
into eva_create_evaluationResult10
|
||||
from fk_eva_create_evaluationResult10 in eva_create_evaluationResult10.DefaultIfEmpty()
|
||||
|
||||
where m_eva_create_evaluation_detail_process.id == id
|
||||
|
||||
orderby m_eva_create_evaluation_detail_process.created descending
|
||||
select new eva_create_evaluation_detail_processWithSelectionViewModel()
|
||||
{
|
||||
id = m_eva_create_evaluation_detail_process.id,
|
||||
evaluation_round = fk_eva_create_evaluationResult10.eva_performance_plan.theTime.ToString(),
|
||||
employee_code = fk_external_employee.employee_no,
|
||||
employee_fullname = fk_external_employee.fullname,
|
||||
employee_position = fk_external_employee.position_name,
|
||||
employee_position_type = null,
|
||||
employee_position_level = null,
|
||||
employee_org = fk_external_employee.department_name,
|
||||
chief_fullname = fk_external_chief.fullname,
|
||||
chief_position = fk_external_chief.position_name,
|
||||
create_evaluation_id = m_eva_create_evaluation_detail_process.create_evaluation_id,
|
||||
org_id = fk_external_employee.department_id,
|
||||
search_employee_code = fk_external_employee.employee_no,
|
||||
search_employee_fullname = fk_external_employee.fullname,
|
||||
|
||||
org_id_external_linkage_external_name = fk_external_employee.department_name,
|
||||
|
||||
create_evaluation_score1 = fk_eva_create_evaluationResult10.score1,
|
||||
create_evaluation_score2 = fk_eva_create_evaluationResult10.score2,
|
||||
|
||||
isActive = m_eva_create_evaluation_detail_process.isActive,
|
||||
Created = m_eva_create_evaluation_detail_process.created,
|
||||
Updated = m_eva_create_evaluation_detail_process.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data[0];
|
||||
}
|
||||
public eva_create_evaluation_detail_processWithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var item = Get(id);
|
||||
item.item_org_id = ext.GetDepartmentData();
|
||||
item.item_level_score = (from i in _repository.Context.eva_level_score
|
||||
orderby i.min_score
|
||||
select Mapper.Map<eva_level_scoreViewModel>(i)).ToList();
|
||||
|
||||
return item;
|
||||
}
|
||||
public eva_create_evaluation_detail_processWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_create_evaluation_detail_processWithSelectionViewModel();
|
||||
i.item_org_id = ext.GetDepartmentData();
|
||||
i.item_level_score = (from j in _repository.Context.eva_level_score
|
||||
orderby j.min_score
|
||||
select Mapper.Map<eva_level_scoreViewModel>(i)).ToList();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_processViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id)
|
||||
{
|
||||
var model = new eva_create_evaluation_detail_processSearchModel();
|
||||
model.create_evaluation_id = create_evaluation_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_processViewModel> GetListBySearch(eva_create_evaluation_detail_processSearchModel model)
|
||||
{
|
||||
var allemp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
var data = (
|
||||
from m_eva_create_evaluation_detail_process in _repository.Context.eva_create_evaluation_detail
|
||||
|
||||
join fk_external_employee in allemp on m_eva_create_evaluation_detail_process.employee_id equals fk_external_employee.id
|
||||
into external_employeeResult
|
||||
from fk_external_employee in external_employeeResult.DefaultIfEmpty()
|
||||
|
||||
join fk_external_chief in allemp on m_eva_create_evaluation_detail_process.chief equals fk_external_chief.id
|
||||
into external_chiefResult
|
||||
from fk_external_chief in external_chiefResult.DefaultIfEmpty()
|
||||
|
||||
join fk_eva_create_evaluation10 in _repository.Context.eva_create_evaluation on m_eva_create_evaluation_detail_process.create_evaluation_id equals fk_eva_create_evaluation10.id
|
||||
into eva_create_evaluationResult10
|
||||
from fk_eva_create_evaluationResult10 in eva_create_evaluationResult10.DefaultIfEmpty()
|
||||
|
||||
where 1 == 1
|
||||
&& (m_eva_create_evaluation_detail_process.create_evaluation_id == model.create_evaluation_id || !model.create_evaluation_id.HasValue)
|
||||
&& (fk_external_employee.department_id == model.org_id || !model.org_id.HasValue)
|
||||
&& (fk_external_employee.employee_no == model.search_employee_code || string.IsNullOrEmpty(model.search_employee_code))
|
||||
&& (fk_external_employee.fullname.Contains(model.search_employee_fullname) || string.IsNullOrEmpty(model.search_employee_fullname))
|
||||
|
||||
|
||||
orderby m_eva_create_evaluation_detail_process.created descending
|
||||
select new eva_create_evaluation_detail_processViewModel()
|
||||
{
|
||||
id = m_eva_create_evaluation_detail_process.id,
|
||||
evaluation_round = fk_eva_create_evaluationResult10.eva_performance_plan.theTime.ToString(),
|
||||
employee_code = fk_external_employee.employee_no,
|
||||
employee_fullname = fk_external_employee.fullname,
|
||||
employee_position = fk_external_employee.position_name,
|
||||
employee_position_type = null,
|
||||
employee_position_level = null,
|
||||
employee_org = fk_external_employee.department_name,
|
||||
chief_fullname = fk_external_chief.fullname,
|
||||
chief_position = fk_external_chief.position_name,
|
||||
create_evaluation_id = m_eva_create_evaluation_detail_process.create_evaluation_id,
|
||||
org_id = fk_external_employee.department_id,
|
||||
search_employee_code = fk_external_employee.employee_no,
|
||||
search_employee_fullname = fk_external_employee.fullname,
|
||||
|
||||
org_id_external_linkage_external_name = fk_external_employee.department_name,
|
||||
|
||||
isActive = m_eva_create_evaluation_detail_process.isActive,
|
||||
Created = m_eva_create_evaluation_detail_process.created,
|
||||
Updated = m_eva_create_evaluation_detail_process.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
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_processViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public string evaluation_round { get; set; }
|
||||
|
||||
public string employee_code { get; set; }
|
||||
|
||||
public string employee_fullname { get; set; }
|
||||
|
||||
public string employee_position { get; set; }
|
||||
|
||||
public string employee_position_type { get; set; }
|
||||
|
||||
public string employee_position_level { get; set; }
|
||||
|
||||
public string employee_org { get; set; }
|
||||
|
||||
public string chief_fullname { get; set; }
|
||||
|
||||
public string chief_position { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? org_id { get; set; }
|
||||
|
||||
public string search_employee_code { get; set; }
|
||||
|
||||
public string search_employee_fullname { get; set; }
|
||||
|
||||
public Guid? create_evaluation_id_eva_create_evaluation_performance_plan_id { get; set; }
|
||||
public string org_id_external_linkage_external_name { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_create_evaluation_detail_processWithSelectionViewModel: eva_create_evaluation_detail_processViewModel
|
||||
{
|
||||
public List<external_linkageViewModel> item_org_id { get; set; }
|
||||
|
||||
public List<eva_level_scoreViewModel> item_level_score { get; set; }
|
||||
|
||||
public decimal? create_evaluation_score1 { get; set; }
|
||||
|
||||
public decimal? create_evaluation_score2 { 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_review01Service : IBaseService<int, eva_create_evaluation_detail_review01InputModel, eva_create_evaluation_detail_review01ViewModel>
|
||||
{
|
||||
new eva_create_evaluation_detail_review01ViewModel Insert(eva_create_evaluation_detail_review01InputModel model);
|
||||
new eva_create_evaluation_detail_review01ViewModel Update(int id, eva_create_evaluation_detail_review01InputModel model);
|
||||
List<eva_create_evaluation_detail_review01ViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id);
|
||||
List<eva_create_evaluation_detail_review01ViewModel> GetListBySearch(eva_create_evaluation_detail_review01SearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_create_evaluation_detail_review01InputModel> model);
|
||||
eva_create_evaluation_detail_review01WithSelectionViewModel GetWithSelection(int id);
|
||||
eva_create_evaluation_detail_review01WithSelectionViewModel 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_review01InputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? supervisor1 { get; set; }
|
||||
|
||||
public string supervisor1_result { get; set; }
|
||||
|
||||
public string supervisor1_remark { get; set; }
|
||||
|
||||
public DateTime? supervisor1_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_review01ReportRequestModel : eva_create_evaluation_detail_review01SearchModel
|
||||
{
|
||||
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_review01SearchModel
|
||||
{
|
||||
|
||||
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_review01Service : Ieva_create_evaluation_detail_review01Service
|
||||
{
|
||||
private IBaseRepository2<eva_create_evaluation_detailEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
|
||||
public eva_create_evaluation_detail_review01Service(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_review01InputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detailEntity>(model);
|
||||
}
|
||||
private List<eva_create_evaluation_detailEntity> GetEntityList(List<eva_create_evaluation_detail_review01InputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detailEntity>>(models);
|
||||
}
|
||||
private eva_create_evaluation_detail_review01ViewModel GetDto(eva_create_evaluation_detailEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detail_review01ViewModel>(entity);
|
||||
}
|
||||
private List<eva_create_evaluation_detail_review01ViewModel> GetDtoList(List<eva_create_evaluation_detailEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detail_review01ViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_create_evaluation_detail_review01ViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_create_evaluation_detail_review01WithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_create_evaluation_detail_review01WithSelectionViewModel>(entity);
|
||||
i.item_supervisor1_result = (from x in ext.GetAgreeDisagree() select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_create_evaluation_detail_review01WithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_create_evaluation_detail_review01WithSelectionViewModel();
|
||||
i.item_supervisor1_result = (from x in ext.GetAgreeDisagree() select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_review01ViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id)
|
||||
{
|
||||
var model = new eva_create_evaluation_detail_review01SearchModel();
|
||||
model.create_evaluation_id = create_evaluation_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_review01ViewModel> GetListBySearch(eva_create_evaluation_detail_review01SearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_create_evaluation_detail_review01 in _repository.Context.eva_create_evaluation_detail
|
||||
|
||||
join fk_external_linkage3 in ext.GetAgreeDisagree() on m_eva_create_evaluation_detail_review01.supervisor1_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_review01.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_create_evaluation_detail_review01.create_evaluation_id == model.create_evaluation_id || !model.create_evaluation_id.HasValue)
|
||||
|
||||
|
||||
orderby m_eva_create_evaluation_detail_review01.created descending
|
||||
select new eva_create_evaluation_detail_review01ViewModel()
|
||||
{
|
||||
id = m_eva_create_evaluation_detail_review01.id,
|
||||
create_evaluation_id = m_eva_create_evaluation_detail_review01.create_evaluation_id,
|
||||
supervisor1 = m_eva_create_evaluation_detail_review01.supervisor1,
|
||||
supervisor1_result = m_eva_create_evaluation_detail_review01.supervisor1_result,
|
||||
supervisor1_remark = m_eva_create_evaluation_detail_review01.supervisor1_remark,
|
||||
supervisor1_date = m_eva_create_evaluation_detail_review01.supervisor1_date,
|
||||
|
||||
supervisor1_result_external_linkage_external_name = fk_external_linkageResult3.external_name,
|
||||
|
||||
isActive = m_eva_create_evaluation_detail_review01.isActive,
|
||||
Created = m_eva_create_evaluation_detail_review01.created,
|
||||
Updated = m_eva_create_evaluation_detail_review01.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_review01ViewModel Insert(eva_create_evaluation_detail_review01InputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detail_review01ViewModel Update(int id, eva_create_evaluation_detail_review01InputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.create_evaluation_id = model.create_evaluation_id;
|
||||
existingEntity.supervisor1 = model.supervisor1;
|
||||
existingEntity.supervisor1_result = model.supervisor1_result;
|
||||
existingEntity.supervisor1_remark = model.supervisor1_remark;
|
||||
existingEntity.supervisor1_date = model.supervisor1_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_review01InputModel> 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.supervisor1 = i.supervisor1;
|
||||
existingEntity.supervisor1_result = null; //i.supervisor1_result;
|
||||
existingEntity.supervisor1_remark = i.supervisor1_remark;
|
||||
existingEntity.supervisor1_date = i.supervisor1_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_review01ViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_create_evaluation_detail_review01ViewModel 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_review01ViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? supervisor1 { get; set; }
|
||||
|
||||
public string supervisor1_result { get; set; }
|
||||
|
||||
public string supervisor1_remark { get; set; }
|
||||
|
||||
public DateTime? supervisor1_date { get; set; }
|
||||
|
||||
public string txt_supervisor1_date { get { return MyHelper.GetDateStringForReport(this.supervisor1_date); } }
|
||||
|
||||
public string supervisor1_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_review01WithSelectionViewModel: eva_create_evaluation_detail_review01ViewModel
|
||||
{
|
||||
public List<external_linkageViewModel> item_supervisor1_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_review02Service : IBaseService<int, eva_create_evaluation_detail_review02InputModel, eva_create_evaluation_detail_review02ViewModel>
|
||||
{
|
||||
new eva_create_evaluation_detail_review02ViewModel Insert(eva_create_evaluation_detail_review02InputModel model);
|
||||
new eva_create_evaluation_detail_review02ViewModel Update(int id, eva_create_evaluation_detail_review02InputModel model);
|
||||
List<eva_create_evaluation_detail_review02ViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id);
|
||||
List<eva_create_evaluation_detail_review02ViewModel> GetListBySearch(eva_create_evaluation_detail_review02SearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_create_evaluation_detail_review02InputModel> model);
|
||||
eva_create_evaluation_detail_review02WithSelectionViewModel GetWithSelection(int id);
|
||||
eva_create_evaluation_detail_review02WithSelectionViewModel 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_review02InputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? supervisor2 { get; set; }
|
||||
|
||||
public string supervisor2_result { get; set; }
|
||||
|
||||
public string supervisor2_remark { get; set; }
|
||||
|
||||
public DateTime? supervisor2_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_review02ReportRequestModel : eva_create_evaluation_detail_review02SearchModel
|
||||
{
|
||||
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_review02SearchModel
|
||||
{
|
||||
|
||||
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_review02Service : Ieva_create_evaluation_detail_review02Service
|
||||
{
|
||||
private IBaseRepository2<eva_create_evaluation_detailEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
|
||||
public eva_create_evaluation_detail_review02Service(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_review02InputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detailEntity>(model);
|
||||
}
|
||||
private List<eva_create_evaluation_detailEntity> GetEntityList(List<eva_create_evaluation_detail_review02InputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detailEntity>>(models);
|
||||
}
|
||||
private eva_create_evaluation_detail_review02ViewModel GetDto(eva_create_evaluation_detailEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detail_review02ViewModel>(entity);
|
||||
}
|
||||
private List<eva_create_evaluation_detail_review02ViewModel> GetDtoList(List<eva_create_evaluation_detailEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detail_review02ViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_create_evaluation_detail_review02ViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_create_evaluation_detail_review02WithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_create_evaluation_detail_review02WithSelectionViewModel>(entity);
|
||||
i.item_supervisor2_result = (from x in ext.GetAgreeDisagree() select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_create_evaluation_detail_review02WithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_create_evaluation_detail_review02WithSelectionViewModel();
|
||||
i.item_supervisor2_result = (from x in ext.GetAgreeDisagree() select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_review02ViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id)
|
||||
{
|
||||
var model = new eva_create_evaluation_detail_review02SearchModel();
|
||||
model.create_evaluation_id = create_evaluation_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_review02ViewModel> GetListBySearch(eva_create_evaluation_detail_review02SearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_create_evaluation_detail_review02 in _repository.Context.eva_create_evaluation_detail
|
||||
|
||||
join fk_external_linkage3 in ext.GetAgreeDisagree() on m_eva_create_evaluation_detail_review02.supervisor2_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_review02.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_create_evaluation_detail_review02.create_evaluation_id == model.create_evaluation_id || !model.create_evaluation_id.HasValue)
|
||||
|
||||
|
||||
orderby m_eva_create_evaluation_detail_review02.created descending
|
||||
select new eva_create_evaluation_detail_review02ViewModel()
|
||||
{
|
||||
id = m_eva_create_evaluation_detail_review02.id,
|
||||
create_evaluation_id = m_eva_create_evaluation_detail_review02.create_evaluation_id,
|
||||
supervisor2 = m_eva_create_evaluation_detail_review02.supervisor2,
|
||||
supervisor2_result = m_eva_create_evaluation_detail_review02.supervisor2_result,
|
||||
supervisor2_remark = m_eva_create_evaluation_detail_review02.supervisor2_remark,
|
||||
supervisor2_date = m_eva_create_evaluation_detail_review02.supervisor2_date,
|
||||
|
||||
supervisor2_result_external_linkage_external_name = fk_external_linkageResult3.external_name,
|
||||
|
||||
isActive = m_eva_create_evaluation_detail_review02.isActive,
|
||||
Created = m_eva_create_evaluation_detail_review02.created,
|
||||
Updated = m_eva_create_evaluation_detail_review02.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_review02ViewModel Insert(eva_create_evaluation_detail_review02InputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detail_review02ViewModel Update(int id, eva_create_evaluation_detail_review02InputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.create_evaluation_id = model.create_evaluation_id;
|
||||
existingEntity.supervisor2 = model.supervisor2;
|
||||
existingEntity.supervisor2_result = model.supervisor2_result;
|
||||
existingEntity.supervisor2_remark = model.supervisor2_remark;
|
||||
existingEntity.supervisor2_date = model.supervisor2_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_review02InputModel> 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.supervisor2 = i.supervisor2;
|
||||
existingEntity.supervisor2_result = i.supervisor2_result;
|
||||
existingEntity.supervisor2_remark = i.supervisor2_remark;
|
||||
existingEntity.supervisor2_date = i.supervisor2_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_review02ViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_create_evaluation_detail_review02ViewModel 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_review02ViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public int? supervisor2 { get; set; }
|
||||
|
||||
public string supervisor2_result { get; set; }
|
||||
|
||||
public string supervisor2_remark { get; set; }
|
||||
|
||||
public DateTime? supervisor2_date { get; set; }
|
||||
|
||||
public string txt_supervisor2_date { get { return MyHelper.GetDateStringForReport(this.supervisor2_date); } }
|
||||
|
||||
public string supervisor2_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_review02WithSelectionViewModel: eva_create_evaluation_detail_review02ViewModel
|
||||
{
|
||||
public List<external_linkageViewModel> item_supervisor2_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_statusService : IBaseService<int, eva_create_evaluation_detail_statusInputModel, eva_create_evaluation_detail_statusViewModel>
|
||||
{
|
||||
new eva_create_evaluation_detail_statusViewModel Insert(eva_create_evaluation_detail_statusInputModel model);
|
||||
new eva_create_evaluation_detail_statusViewModel Update(int id, eva_create_evaluation_detail_statusInputModel model);
|
||||
List<eva_create_evaluation_detail_statusViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id);
|
||||
List<eva_create_evaluation_detail_statusViewModel> GetListBySearch(eva_create_evaluation_detail_statusSearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_create_evaluation_detail_statusInputModel> model);
|
||||
eva_create_evaluation_detail_statusWithSelectionViewModel GetWithSelection(int id);
|
||||
eva_create_evaluation_detail_statusWithSelectionViewModel 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_create_evaluation_detail_statusInputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public string status_self { get; set; }
|
||||
|
||||
public string status_chief { get; set; }
|
||||
|
||||
public string status_supervisor { 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_statusReportRequestModel : eva_create_evaluation_detail_statusSearchModel
|
||||
{
|
||||
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_statusSearchModel
|
||||
{
|
||||
|
||||
public int id { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
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_statusService : Ieva_create_evaluation_detail_statusService
|
||||
{
|
||||
private IBaseRepository2<eva_create_evaluation_detailEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
|
||||
public eva_create_evaluation_detail_statusService(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_statusInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detailEntity>(model);
|
||||
}
|
||||
private List<eva_create_evaluation_detailEntity> GetEntityList(List<eva_create_evaluation_detail_statusInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detailEntity>>(models);
|
||||
}
|
||||
private eva_create_evaluation_detail_statusViewModel GetDto(eva_create_evaluation_detailEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detail_statusViewModel>(entity);
|
||||
}
|
||||
private List<eva_create_evaluation_detail_statusViewModel> GetDtoList(List<eva_create_evaluation_detailEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detail_statusViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_create_evaluation_detail_statusViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_create_evaluation_detail_statusWithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_create_evaluation_detail_statusWithSelectionViewModel>(entity);
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_create_evaluation_detail_statusWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_create_evaluation_detail_statusWithSelectionViewModel();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_statusViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id)
|
||||
{
|
||||
var model = new eva_create_evaluation_detail_statusSearchModel();
|
||||
model.create_evaluation_id = create_evaluation_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_statusViewModel> GetListBySearch(eva_create_evaluation_detail_statusSearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_create_evaluation_detail_status in _repository.Context.eva_create_evaluation_detail
|
||||
|
||||
|
||||
where 1==1
|
||||
//&& (m_eva_create_evaluation_detail_status.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_create_evaluation_detail_status.create_evaluation_id == model.create_evaluation_id || !model.create_evaluation_id.HasValue)
|
||||
|
||||
|
||||
orderby m_eva_create_evaluation_detail_status.created descending
|
||||
select new eva_create_evaluation_detail_statusViewModel()
|
||||
{
|
||||
id = m_eva_create_evaluation_detail_status.id,
|
||||
create_evaluation_id = m_eva_create_evaluation_detail_status.create_evaluation_id,
|
||||
status_self = m_eva_create_evaluation_detail_status.status_self,
|
||||
status_chief = m_eva_create_evaluation_detail_status.status_chief,
|
||||
status_supervisor = m_eva_create_evaluation_detail_status.status_supervisor,
|
||||
|
||||
|
||||
isActive = m_eva_create_evaluation_detail_status.isActive,
|
||||
Created = m_eva_create_evaluation_detail_status.created,
|
||||
Updated = m_eva_create_evaluation_detail_status.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_statusViewModel Insert(eva_create_evaluation_detail_statusInputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detail_statusViewModel Update(int id, eva_create_evaluation_detail_statusInputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.create_evaluation_id = model.create_evaluation_id;
|
||||
existingEntity.status_self = model.status_self;
|
||||
existingEntity.status_chief = model.status_chief;
|
||||
existingEntity.status_supervisor = model.status_supervisor;
|
||||
|
||||
|
||||
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_statusInputModel> 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.status_self = i.status_self;
|
||||
existingEntity.status_chief = i.status_chief;
|
||||
existingEntity.status_supervisor = i.status_supervisor;
|
||||
|
||||
|
||||
_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_statusViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_create_evaluation_detail_statusViewModel 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,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_create_evaluation_detail_statusViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public string status_self { get; set; }
|
||||
|
||||
public string status_chief { get; set; }
|
||||
|
||||
public string status_supervisor { 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_create_evaluation_detail_statusWithSelectionViewModel: eva_create_evaluation_detail_statusViewModel
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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_summary1Service : IBaseService<int, eva_create_evaluation_detail_summary1InputModel, eva_create_evaluation_detail_summary1ViewModel>
|
||||
{
|
||||
new eva_create_evaluation_detail_summary1ViewModel Insert(eva_create_evaluation_detail_summary1InputModel model);
|
||||
new eva_create_evaluation_detail_summary1ViewModel Update(int id, eva_create_evaluation_detail_summary1InputModel model);
|
||||
List<eva_create_evaluation_detail_summary1ViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id);
|
||||
List<eva_create_evaluation_detail_summary1ViewModel> GetListBySearch(eva_create_evaluation_detail_summary1SearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_create_evaluation_detail_summary1InputModel> model);
|
||||
eva_create_evaluation_detail_summary1WithSelectionViewModel GetWithSelection(int id);
|
||||
eva_create_evaluation_detail_summary1WithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
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_summary1InputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public decimal? total_summary_chief { get; set; }
|
||||
|
||||
public decimal? Final_summary_chief { get; set; }
|
||||
|
||||
public decimal? total_summary_competency_chief { get; set; }
|
||||
|
||||
public decimal? Final_summary_competency_chief { get; set; }
|
||||
|
||||
public decimal? achievement_chief { get; set; }
|
||||
|
||||
public decimal? competency_chief { get; set; }
|
||||
|
||||
public decimal? score_chief { get; set; }
|
||||
|
||||
public string level_score_chief { 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_summary1ReportRequestModel : eva_create_evaluation_detail_summary1SearchModel
|
||||
{
|
||||
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_summary1SearchModel
|
||||
{
|
||||
|
||||
public int id { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user