First Initial
This commit is contained in:
@@ -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; }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user