First Initial
This commit is contained in:
28
Models/eva_salary_cylinder/Ieva_salary_cylinderService.cs
Normal file
28
Models/eva_salary_cylinder/Ieva_salary_cylinderService.cs
Normal file
@@ -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_salary_cylinderService : IBaseService<int, eva_salary_cylinderInputModel, eva_salary_cylinderViewModel>
|
||||
{
|
||||
new eva_salary_cylinderViewModel Insert(eva_salary_cylinderInputModel model);
|
||||
new eva_salary_cylinderViewModel Update(int id, eva_salary_cylinderInputModel model);
|
||||
List<eva_salary_cylinderViewModel> GetListByposition_type(int? position_type);
|
||||
List<eva_salary_cylinderViewModel> GetListBySearch(eva_salary_cylinderSearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_salary_cylinderInputModel> model);
|
||||
eva_salary_cylinderWithSelectionViewModel GetWithSelection(int id);
|
||||
eva_salary_cylinderWithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
35
Models/eva_salary_cylinder/eva_salary_cylinderEntity.cs
Normal file
35
Models/eva_salary_cylinder/eva_salary_cylinderEntity.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
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_salary_cylinderEntity : BaseEntity2<int>
|
||||
{
|
||||
|
||||
|
||||
public int? position_type { get; set; }
|
||||
|
||||
public int? position_level { get; set; }
|
||||
|
||||
public decimal? temporary_min { get; set; }
|
||||
|
||||
public decimal? themin { get; set; }
|
||||
|
||||
public decimal? themax { get; set; }
|
||||
|
||||
public decimal? middle { get; set; }
|
||||
|
||||
public decimal? cost_living { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
36
Models/eva_salary_cylinder/eva_salary_cylinderInputModel.cs
Normal file
36
Models/eva_salary_cylinder/eva_salary_cylinderInputModel.cs
Normal file
@@ -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_salary_cylinderInputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? position_type { get; set; }
|
||||
|
||||
public int? position_level { get; set; }
|
||||
|
||||
public decimal? temporary_min { get; set; }
|
||||
|
||||
public decimal? themin { get; set; }
|
||||
|
||||
public decimal? themax { get; set; }
|
||||
|
||||
public decimal? middle { get; set; }
|
||||
|
||||
public decimal? cost_living { 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_salary_cylinderReportRequestModel : eva_salary_cylinderSearchModel
|
||||
{
|
||||
public string filetype { get; set; }
|
||||
|
||||
public string contentType { get { return MyHelper.GetContentType(filetype); } }
|
||||
}
|
||||
}
|
||||
|
||||
21
Models/eva_salary_cylinder/eva_salary_cylinderSearchModel.cs
Normal file
21
Models/eva_salary_cylinder/eva_salary_cylinderSearchModel.cs
Normal file
@@ -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_salary_cylinderSearchModel
|
||||
{
|
||||
|
||||
public int? position_type { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
284
Models/eva_salary_cylinder/eva_salary_cylinderService.cs
Normal file
284
Models/eva_salary_cylinder/eva_salary_cylinderService.cs
Normal file
@@ -0,0 +1,284 @@
|
||||
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_salary_cylinderService : Ieva_salary_cylinderService
|
||||
{
|
||||
private IBaseRepository2<eva_salary_cylinderEntity, int> _repository;
|
||||
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;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_salary_cylinderEntity GetEntity(eva_salary_cylinderInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_salary_cylinderEntity>(model);
|
||||
}
|
||||
private List<eva_salary_cylinderEntity> GetEntityList(List<eva_salary_cylinderInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_salary_cylinderEntity>>(models);
|
||||
}
|
||||
private eva_salary_cylinderViewModel GetDto(eva_salary_cylinderEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_salary_cylinderViewModel>(entity);
|
||||
}
|
||||
private List<eva_salary_cylinderViewModel> GetDtoList(List<eva_salary_cylinderEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_salary_cylinderViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_salary_cylinderViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_salary_cylinderWithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_salary_cylinderWithSelectionViewModel>(entity);
|
||||
i.item_position_type = (from x in ext.Gethrm_position_types() select x).ToList();
|
||||
i.item_position_level = (from x in ext.Gethrm_position_levels() select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_salary_cylinderWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_salary_cylinderWithSelectionViewModel();
|
||||
i.item_position_type = (from x in ext.Gethrm_position_types() select x).ToList();
|
||||
i.item_position_level = (from x in ext.Gethrm_position_levels() select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_salary_cylinderViewModel> GetListByposition_type(int? position_type)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_salary_cylinder in _repository.Context.eva_salary_cylinder
|
||||
|
||||
join fk_external_linkage1 in ext.Gethrm_position_types() on m_eva_salary_cylinder.position_type equals fk_external_linkage1.id
|
||||
into external_linkageResult1
|
||||
from fk_external_linkageResult1 in external_linkageResult1.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage2 in ext.Gethrm_position_levels() on m_eva_salary_cylinder.position_level equals fk_external_linkage2.id
|
||||
into external_linkageResult2
|
||||
from fk_external_linkageResult2 in external_linkageResult2.DefaultIfEmpty()
|
||||
|
||||
|
||||
where m_eva_salary_cylinder.position_type == position_type || !position_type.HasValue
|
||||
|
||||
orderby m_eva_salary_cylinder.created descending
|
||||
select new eva_salary_cylinderViewModel()
|
||||
{
|
||||
id = m_eva_salary_cylinder.id,
|
||||
position_type = m_eva_salary_cylinder.position_type,
|
||||
position_level = m_eva_salary_cylinder.position_level,
|
||||
temporary_min = m_eva_salary_cylinder.temporary_min,
|
||||
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 ,
|
||||
|
||||
position_type_external_linkage_external_name = fk_external_linkageResult1.external_name,
|
||||
position_level_external_linkage_external_name = fk_external_linkageResult2.external_name,
|
||||
|
||||
isActive = m_eva_salary_cylinder.isActive,
|
||||
Created = m_eva_salary_cylinder.created,
|
||||
Updated = m_eva_salary_cylinder.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public List<eva_salary_cylinderViewModel> GetListBySearch(eva_salary_cylinderSearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_salary_cylinder in _repository.Context.eva_salary_cylinder
|
||||
|
||||
join fk_external_linkage1 in ext.Gethrm_position_types() on m_eva_salary_cylinder.position_type equals fk_external_linkage1.id
|
||||
into external_linkageResult1
|
||||
from fk_external_linkageResult1 in external_linkageResult1.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage2 in ext.Gethrm_position_levels() on m_eva_salary_cylinder.position_level equals fk_external_linkage2.id
|
||||
into external_linkageResult2
|
||||
from fk_external_linkageResult2 in external_linkageResult2.DefaultIfEmpty()
|
||||
|
||||
|
||||
where 1==1
|
||||
&& (m_eva_salary_cylinder.position_type == model.position_type || !model.position_type.HasValue)
|
||||
|
||||
|
||||
orderby m_eva_salary_cylinder.created descending
|
||||
select new eva_salary_cylinderViewModel()
|
||||
{
|
||||
id = m_eva_salary_cylinder.id,
|
||||
position_type = m_eva_salary_cylinder.position_type,
|
||||
position_level = m_eva_salary_cylinder.position_level,
|
||||
temporary_min = m_eva_salary_cylinder.temporary_min,
|
||||
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 ,
|
||||
|
||||
position_type_external_linkage_external_name = fk_external_linkageResult1.external_name,
|
||||
position_level_external_linkage_external_name = fk_external_linkageResult2.external_name,
|
||||
|
||||
isActive = m_eva_salary_cylinder.isActive,
|
||||
Created = m_eva_salary_cylinder.created,
|
||||
Updated = m_eva_salary_cylinder.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
public int GetNewPrimaryKey()
|
||||
{
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_salary_cylinder
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if(x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
|
||||
return newkey.Value;
|
||||
}
|
||||
|
||||
public eva_salary_cylinderViewModel Insert(eva_salary_cylinderInputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_salary_cylinderViewModel Update(int id, eva_salary_cylinderInputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.position_type = model.position_type;
|
||||
existingEntity.position_level = model.position_level;
|
||||
existingEntity.temporary_min = model.temporary_min;
|
||||
existingEntity.themin = model.themin;
|
||||
existingEntity.themax = model.themax;
|
||||
existingEntity.middle = model.middle;
|
||||
existingEntity.cost_living = model.cost_living ;
|
||||
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_salary_cylinderInputModel> 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 ;
|
||||
|
||||
|
||||
_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_salary_cylinderViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_salary_cylinderViewModel 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
|
||||
}
|
||||
}
|
||||
35
Models/eva_salary_cylinder/eva_salary_cylinderViewModel.cs
Normal file
35
Models/eva_salary_cylinder/eva_salary_cylinderViewModel.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
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_salary_cylinderViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? position_type { get; set; }
|
||||
|
||||
public int? position_level { get; set; }
|
||||
|
||||
public decimal? temporary_min { get; set; }
|
||||
|
||||
public decimal? themin { get; set; }
|
||||
|
||||
public decimal? themax { get; set; }
|
||||
|
||||
public decimal? middle { get; set; }
|
||||
|
||||
public decimal? cost_living { get; set; }
|
||||
|
||||
public string position_type_external_linkage_external_name { get; set; }
|
||||
public string position_level_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_salary_cylinderWithSelectionViewModel: eva_salary_cylinderViewModel
|
||||
{
|
||||
public List<external_linkageViewModel> item_position_type { get; set; }
|
||||
public List<external_linkageViewModel> item_position_level { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user