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_postponementService : IBaseService<int, eva_adjust_postponementInputModel, eva_adjust_postponementViewModel>
|
||||
{
|
||||
new eva_adjust_postponementViewModel Insert(eva_adjust_postponementInputModel model);
|
||||
new eva_adjust_postponementViewModel Update(int id, eva_adjust_postponementInputModel model);
|
||||
List<eva_adjust_postponementViewModel> GetListByfiscal_year(int? fiscal_year);
|
||||
List<eva_adjust_postponementViewModel> GetListBySearch(eva_adjust_postponementSearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_adjust_postponementInputModel> model);
|
||||
eva_adjust_postponementWithSelectionViewModel GetWithSelection(int id);
|
||||
eva_adjust_postponementWithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
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_adjust_postponementEntity : BaseEntity2<int>
|
||||
{
|
||||
|
||||
|
||||
public int? fiscal_year { get; set; }
|
||||
|
||||
public DateTime? theDate { get; set; }
|
||||
|
||||
public int? theRound { get; set; }
|
||||
|
||||
[ForeignKey("create_evaluation_id")]
|
||||
public eva_create_evaluationEntity eva_create_evaluation { 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? limit_frame_quota { get; set; }
|
||||
|
||||
public decimal? percentage { get; set; }
|
||||
|
||||
[MaxLength(100)]
|
||||
public string command_no { get; set; }
|
||||
|
||||
public int? managed_by { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
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_postponementInputModel
|
||||
{
|
||||
|
||||
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? limit_frame_quota { get; set; }
|
||||
|
||||
public decimal? percentage { get; set; }
|
||||
|
||||
public string command_no { get; set; }
|
||||
|
||||
public int? managed_by { 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_postponementReportRequestModel : eva_adjust_postponementSearchModel
|
||||
{
|
||||
public string filetype { get; set; }
|
||||
|
||||
public string contentType { get { return MyHelper.GetContentType(filetype); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_postponementSearchModel
|
||||
{
|
||||
|
||||
public int id { get; set; }
|
||||
|
||||
public int? fiscal_year { get; set; }
|
||||
|
||||
public int? theRound { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
272
Models/eva_adjust_postponement/eva_adjust_postponementService.cs
Normal file
272
Models/eva_adjust_postponement/eva_adjust_postponementService.cs
Normal file
@@ -0,0 +1,272 @@
|
||||
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_postponementService : Ieva_adjust_postponementService
|
||||
{
|
||||
private IBaseRepository2<eva_adjust_postponementEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
|
||||
public eva_adjust_postponementService(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_postponementInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_adjust_postponementEntity>(model);
|
||||
}
|
||||
private List<eva_adjust_postponementEntity> GetEntityList(List<eva_adjust_postponementInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_adjust_postponementEntity>>(models);
|
||||
}
|
||||
private eva_adjust_postponementViewModel GetDto(eva_adjust_postponementEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_adjust_postponementViewModel>(entity);
|
||||
}
|
||||
private List<eva_adjust_postponementViewModel> GetDtoList(List<eva_adjust_postponementEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_adjust_postponementViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_adjust_postponementViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_adjust_postponementWithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_adjust_postponementWithSelectionViewModel>(entity);
|
||||
i.item_create_evaluation_id = (from x in _repository.Context.eva_create_evaluation select x).ToList();
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
i.item_managed_by = all_emp.ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_adjust_postponementWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_adjust_postponementWithSelectionViewModel();
|
||||
i.item_create_evaluation_id = (from x in _repository.Context.eva_create_evaluation select x).ToList();
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
i.item_managed_by = all_emp.ToList();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_adjust_postponementViewModel> GetListByfiscal_year(int? fiscal_year)
|
||||
{
|
||||
var model = new eva_adjust_postponementSearchModel();
|
||||
model.fiscal_year = fiscal_year;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_adjust_postponementViewModel> GetListBySearch(eva_adjust_postponementSearchModel model)
|
||||
{
|
||||
var all_emp = emp.GetListByemployee_type(null, null);
|
||||
|
||||
var data = (
|
||||
from m_eva_adjust_postponement in _repository.Context.eva_adjust_postponement
|
||||
|
||||
join fk_eva_create_evaluation4 in _repository.Context.eva_create_evaluation on m_eva_adjust_postponement.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_linkage11 in all_emp on m_eva_adjust_postponement.managed_by equals fk_external_linkage11.id
|
||||
into external_linkageResult11
|
||||
from fk_external_linkageResult11 in external_linkageResult11.DefaultIfEmpty()
|
||||
|
||||
|
||||
where 1==1
|
||||
//&& (m_eva_adjust_postponement.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_adjust_postponement.fiscal_year == model.fiscal_year || !model.fiscal_year.HasValue)
|
||||
&& (m_eva_adjust_postponement.theRound == model.theRound || !model.theRound.HasValue)
|
||||
|
||||
|
||||
orderby m_eva_adjust_postponement.created descending
|
||||
select new eva_adjust_postponementViewModel()
|
||||
{
|
||||
id = m_eva_adjust_postponement.id,
|
||||
fiscal_year = m_eva_adjust_postponement.fiscal_year,
|
||||
theDate = m_eva_adjust_postponement.theDate,
|
||||
theRound = m_eva_adjust_postponement.theRound,
|
||||
create_evaluation_id = m_eva_adjust_postponement.create_evaluation_id,
|
||||
limit = m_eva_adjust_postponement.limit,
|
||||
limit_frame = m_eva_adjust_postponement.limit_frame,
|
||||
limit_quota = m_eva_adjust_postponement.limit_quota,
|
||||
limit_frame_quota = m_eva_adjust_postponement.limit_frame_quota,
|
||||
percentage = m_eva_adjust_postponement.percentage,
|
||||
command_no = m_eva_adjust_postponement.command_no,
|
||||
managed_by = m_eva_adjust_postponement.managed_by,
|
||||
|
||||
create_evaluation_id_eva_create_evaluation_performance_plan_id = fk_eva_create_evaluationResult4.performance_plan_id,
|
||||
managed_by_external_linkage_external_name = fk_external_linkageResult11.fullname,
|
||||
|
||||
isActive = m_eva_adjust_postponement.isActive,
|
||||
Created = m_eva_adjust_postponement.created,
|
||||
Updated = m_eva_adjust_postponement.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_postponementViewModel Insert(eva_adjust_postponementInputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_adjust_postponementViewModel Update(int id, eva_adjust_postponementInputModel 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.limit_frame_quota = model.limit_frame_quota;
|
||||
existingEntity.percentage = model.percentage;
|
||||
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_postponementInputModel> 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.limit_frame_quota = i.limit_frame_quota;
|
||||
existingEntity.percentage = i.percentage;
|
||||
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_postponementViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_adjust_postponementViewModel 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,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_postponementViewModel : 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? limit_frame_quota { get; set; }
|
||||
|
||||
public decimal? percentage { get; set; }
|
||||
|
||||
public string command_no { get; set; }
|
||||
|
||||
public int? managed_by { 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; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_adjust_postponementWithSelectionViewModel: eva_adjust_postponementViewModel
|
||||
{
|
||||
public List<eva_create_evaluationEntity> item_create_evaluation_id { get; set; }
|
||||
public List<external_employeeViewModel> item_managed_by { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user