เพิ่มคอลัม เงินประจำตำแหน่ง และค่าตอบแทน รายเดือน
This commit is contained in:
@@ -20,14 +20,14 @@ namespace TodoAPI2.Models
|
||||
public class eva_salary_cylinderService : Ieva_salary_cylinderService
|
||||
{
|
||||
private IBaseRepository2<eva_salary_cylinderEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
|
||||
public eva_salary_cylinderService(IBaseRepository2<eva_salary_cylinderEntity, int> repository, IMyDatabase mydb, Iexternal_linkageService inext)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
@@ -47,7 +47,7 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
return Mapper.Map<List<eva_salary_cylinderViewModel>>(entities);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
@@ -93,7 +93,7 @@ namespace TodoAPI2.Models
|
||||
from fk_external_linkageResult2 in external_linkageResult2.DefaultIfEmpty()
|
||||
|
||||
|
||||
where m_eva_salary_cylinder.position_type == position_type || !position_type.HasValue
|
||||
where m_eva_salary_cylinder.position_type == position_type || !position_type.HasValue
|
||||
|
||||
orderby m_eva_salary_cylinder.created descending
|
||||
select new eva_salary_cylinderViewModel()
|
||||
@@ -105,7 +105,9 @@ namespace TodoAPI2.Models
|
||||
themin = m_eva_salary_cylinder.themin,
|
||||
themax = m_eva_salary_cylinder.themax,
|
||||
middle = m_eva_salary_cylinder.middle,
|
||||
cost_living = m_eva_salary_cylinder.cost_living ,
|
||||
cost_living = m_eva_salary_cylinder.cost_living,
|
||||
position_allowance = m_eva_salary_cylinder.position_allowance,
|
||||
monthly_compensation = m_eva_salary_cylinder.monthly_compensation,
|
||||
|
||||
position_type_external_linkage_external_name = fk_external_linkageResult1.external_name,
|
||||
position_level_external_linkage_external_name = fk_external_linkageResult2.external_name,
|
||||
@@ -119,7 +121,7 @@ namespace TodoAPI2.Models
|
||||
return data;
|
||||
}
|
||||
|
||||
public List<eva_salary_cylinderViewModel> GetListBySearch(eva_salary_cylinderSearchModel model)
|
||||
public List<eva_salary_cylinderViewModel> GetListBySearch(eva_salary_cylinderSearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_salary_cylinder in _repository.Context.eva_salary_cylinder
|
||||
@@ -133,7 +135,7 @@ namespace TodoAPI2.Models
|
||||
from fk_external_linkageResult2 in external_linkageResult2.DefaultIfEmpty()
|
||||
|
||||
|
||||
where 1==1
|
||||
where 1 == 1
|
||||
&& (m_eva_salary_cylinder.position_type == model.position_type || !model.position_type.HasValue)
|
||||
|
||||
|
||||
@@ -147,7 +149,9 @@ namespace TodoAPI2.Models
|
||||
themin = m_eva_salary_cylinder.themin,
|
||||
themax = m_eva_salary_cylinder.themax,
|
||||
middle = m_eva_salary_cylinder.middle,
|
||||
cost_living = m_eva_salary_cylinder.cost_living ,
|
||||
cost_living = m_eva_salary_cylinder.cost_living,
|
||||
position_allowance = m_eva_salary_cylinder.position_allowance,
|
||||
monthly_compensation = m_eva_salary_cylinder.monthly_compensation,
|
||||
|
||||
position_type_external_linkage_external_name = fk_external_linkageResult1.external_name,
|
||||
position_level_external_linkage_external_name = fk_external_linkageResult2.external_name,
|
||||
@@ -170,10 +174,10 @@ namespace TodoAPI2.Models
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_salary_cylinder
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if(x.Count > 0)
|
||||
if (x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
@@ -189,7 +193,7 @@ namespace TodoAPI2.Models
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
@@ -204,33 +208,35 @@ namespace TodoAPI2.Models
|
||||
existingEntity.themin = model.themin;
|
||||
existingEntity.themax = model.themax;
|
||||
existingEntity.middle = model.middle;
|
||||
existingEntity.cost_living = model.cost_living ;
|
||||
|
||||
existingEntity.cost_living = model.cost_living;
|
||||
existingEntity.position_allowance = model.position_allowance;
|
||||
existingEntity.monthly_compensation = model.monthly_compensation;
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_salary_cylinderInputModel> model)
|
||||
public string UpdateMultiple(List<eva_salary_cylinderInputModel> model)
|
||||
{
|
||||
foreach(var i in model)
|
||||
foreach (var i in model)
|
||||
{
|
||||
if (i.active_mode == "1" && i.id.HasValue) // update
|
||||
{
|
||||
{
|
||||
var existingEntity = _repository.Get(i.id.Value);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.position_type = i.position_type;
|
||||
existingEntity.position_level = i.position_level;
|
||||
existingEntity.temporary_min = i.temporary_min;
|
||||
existingEntity.themin = i.themin;
|
||||
existingEntity.themax = i.themax;
|
||||
existingEntity.middle = i.middle;
|
||||
existingEntity.cost_living = i.cost_living ;
|
||||
|
||||
existingEntity.position_type = i.position_type;
|
||||
existingEntity.position_level = i.position_level;
|
||||
existingEntity.temporary_min = i.temporary_min;
|
||||
existingEntity.themin = i.themin;
|
||||
existingEntity.themax = i.themax;
|
||||
existingEntity.middle = i.middle;
|
||||
existingEntity.cost_living = i.cost_living;
|
||||
existingEntity.position_allowance = i.position_allowance;
|
||||
existingEntity.monthly_compensation = i.monthly_compensation;
|
||||
|
||||
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
|
||||
}
|
||||
@@ -242,15 +248,15 @@ namespace TodoAPI2.Models
|
||||
_repository.InsertWithoutCommit(entity);
|
||||
}
|
||||
else if (i.active_mode == "0" && i.id.HasValue) // remove
|
||||
{
|
||||
{
|
||||
_repository.DeleteWithoutCommit(i.id.Value);
|
||||
}
|
||||
else if (i.active_mode == "0" && !i.id.HasValue)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
_repository.Context.SaveChanges();
|
||||
_repository.Context.SaveChanges();
|
||||
|
||||
return model.Count().ToString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user