First Initial

This commit is contained in:
Nakorn Rientrakrunchai
2020-02-20 15:02:39 +07:00
commit 8b98125e49
3048 changed files with 760804 additions and 0 deletions

View 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_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();
}
}

View File

@@ -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; }
}
}

View 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_adjust_postponement_normalReportRequestModel : eva_adjust_postponement_normalSearchModel
{
public string filetype { get; set; }
public string contentType { get { return MyHelper.GetContentType(filetype); } }
}
}

View File

@@ -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; }
}
}

View File

@@ -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
}
}

View File

@@ -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; }
}
}

View File

@@ -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; }
}
}