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

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

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

View File

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

View File

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

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

View File

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