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_performance_plan_detailService : IBaseService<Guid, eva_performance_plan_detailInputModel, eva_performance_plan_detailViewModel>
|
||||
{
|
||||
new eva_performance_plan_detailViewModel Insert(eva_performance_plan_detailInputModel model);
|
||||
new eva_performance_plan_detailViewModel Update(Guid id, eva_performance_plan_detailInputModel model);
|
||||
List<eva_performance_plan_detailViewModel> GetListByperformance_plan_id(Guid? performance_plan_id);
|
||||
List<eva_performance_plan_detailViewModel> GetListBySearch(eva_performance_plan_detailSearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_performance_plan_detailInputModel> model);
|
||||
eva_performance_plan_detailWithSelectionViewModel GetWithSelection(Guid id);
|
||||
eva_performance_plan_detailWithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
using System.IO;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_performance_plan_detailEntity : BaseEntity<Guid>
|
||||
{
|
||||
|
||||
[ForeignKey("performance_plan_id")]
|
||||
public eva_performance_planEntity eva_performance_plan { get; set; }
|
||||
public Guid? performance_plan_id { get; set; }
|
||||
|
||||
public int? list_no { get; set; }
|
||||
|
||||
[MaxLength(1000)]
|
||||
public string step { get; set; }
|
||||
|
||||
public DateTime? start_date { get; set; }
|
||||
|
||||
public DateTime? end_date { get; set; }
|
||||
|
||||
[MaxLength(1000)]
|
||||
public string remark { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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_performance_plan_detailInputModel
|
||||
{
|
||||
|
||||
public Guid? id { get; set; }
|
||||
|
||||
public Guid? performance_plan_id { get; set; }
|
||||
|
||||
public int? list_no { get; set; }
|
||||
|
||||
[MaxLength(1000)]
|
||||
public string step { get; set; }
|
||||
|
||||
public DateTime? start_date { get; set; }
|
||||
|
||||
public DateTime? end_date { get; set; }
|
||||
|
||||
[MaxLength(1000)]
|
||||
public string remark { 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_performance_plan_detailReportRequestModel : eva_performance_plan_detailSearchModel
|
||||
{
|
||||
public string filetype { get; set; }
|
||||
|
||||
public string contentType { get { return MyHelper.GetContentType(filetype); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_performance_plan_detailSearchModel
|
||||
{
|
||||
|
||||
public Guid? performance_plan_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,296 @@
|
||||
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_performance_plan_detailService : Ieva_performance_plan_detailService
|
||||
{
|
||||
private IBaseRepository<eva_performance_plan_detailEntity, Guid> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
|
||||
public eva_performance_plan_detailService(IBaseRepository<eva_performance_plan_detailEntity, Guid> repository, IMyDatabase mydb, Iexternal_linkageService inext)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_performance_plan_detailEntity GetEntity(eva_performance_plan_detailInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_performance_plan_detailEntity>(model);
|
||||
}
|
||||
private List<eva_performance_plan_detailEntity> GetEntityList(List<eva_performance_plan_detailInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_performance_plan_detailEntity>>(models);
|
||||
}
|
||||
private eva_performance_plan_detailViewModel GetDto(eva_performance_plan_detailEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_performance_plan_detailViewModel>(entity);
|
||||
}
|
||||
private List<eva_performance_plan_detailViewModel> GetDtoList(List<eva_performance_plan_detailEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_performance_plan_detailViewModel>>(entities);
|
||||
}
|
||||
|
||||
private List<eva_performance_plan_detailEntity> GetListWithoutBase64Fields(IQueryable<eva_performance_plan_detailEntity> listQuery)
|
||||
{
|
||||
return listQuery.Select(c => new eva_performance_plan_detailEntity()
|
||||
{
|
||||
performance_plan_id = c.performance_plan_id,
|
||||
list_no = c.list_no,
|
||||
step = c.step,
|
||||
start_date = c.start_date,
|
||||
end_date = c.end_date,
|
||||
remark = c.remark,
|
||||
|
||||
updated = c.updated,
|
||||
id = c.id,
|
||||
isActive = c.isActive
|
||||
}).ToList();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_performance_plan_detailViewModel Get(Guid id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_performance_plan_detailWithSelectionViewModel GetWithSelection(Guid id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_performance_plan_detailWithSelectionViewModel>(entity);
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_performance_plan_detailWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_performance_plan_detailWithSelectionViewModel();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_performance_plan_detailViewModel> GetListALLeva_performance_plan_detail()
|
||||
{
|
||||
var data = (
|
||||
from m_eva_performance_plan_detail in _repository.Context.eva_performance_plan_detail
|
||||
|
||||
join fk_eva_performance_plan1 in _repository.Context.eva_performance_plan on m_eva_performance_plan_detail.performance_plan_id equals fk_eva_performance_plan1.id
|
||||
into eva_performance_planResult1
|
||||
from fk_eva_performance_planResult1 in eva_performance_planResult1.DefaultIfEmpty()
|
||||
|
||||
orderby m_eva_performance_plan_detail.created descending
|
||||
select new eva_performance_plan_detailViewModel()
|
||||
{
|
||||
id = m_eva_performance_plan_detail.id,
|
||||
performance_plan_id = m_eva_performance_plan_detail.performance_plan_id,
|
||||
list_no = m_eva_performance_plan_detail.list_no,
|
||||
step = m_eva_performance_plan_detail.step,
|
||||
start_date = m_eva_performance_plan_detail.start_date,
|
||||
end_date = m_eva_performance_plan_detail.end_date,
|
||||
remark = m_eva_performance_plan_detail.remark,
|
||||
|
||||
performance_plan_id_eva_performance_plan_fiscal_year = fk_eva_performance_planResult1.fiscal_year,
|
||||
|
||||
isActive = m_eva_performance_plan_detail.isActive,
|
||||
Created = m_eva_performance_plan_detail.created,
|
||||
Updated = m_eva_performance_plan_detail.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public List<eva_performance_plan_detailViewModel> GetListByperformance_plan_id(Guid? performance_plan_id)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_performance_plan_detail in _repository.Context.eva_performance_plan_detail
|
||||
|
||||
join fk_eva_performance_plan1 in _repository.Context.eva_performance_plan on m_eva_performance_plan_detail.performance_plan_id equals fk_eva_performance_plan1.id
|
||||
into eva_performance_planResult1
|
||||
from fk_eva_performance_planResult1 in eva_performance_planResult1.DefaultIfEmpty()
|
||||
|
||||
|
||||
where m_eva_performance_plan_detail.performance_plan_id == performance_plan_id || !performance_plan_id.HasValue
|
||||
|
||||
orderby m_eva_performance_plan_detail.created descending
|
||||
select new eva_performance_plan_detailViewModel()
|
||||
{
|
||||
id = m_eva_performance_plan_detail.id,
|
||||
performance_plan_id = m_eva_performance_plan_detail.performance_plan_id,
|
||||
list_no = m_eva_performance_plan_detail.list_no,
|
||||
step = m_eva_performance_plan_detail.step,
|
||||
start_date = m_eva_performance_plan_detail.start_date,
|
||||
end_date = m_eva_performance_plan_detail.end_date,
|
||||
remark = m_eva_performance_plan_detail.remark,
|
||||
|
||||
performance_plan_id_eva_performance_plan_fiscal_year = fk_eva_performance_planResult1.fiscal_year,
|
||||
|
||||
isActive = m_eva_performance_plan_detail.isActive,
|
||||
Created = m_eva_performance_plan_detail.created,
|
||||
Updated = m_eva_performance_plan_detail.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public List<eva_performance_plan_detailViewModel> GetListBySearch(eva_performance_plan_detailSearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_performance_plan_detail in _repository.Context.eva_performance_plan_detail
|
||||
|
||||
join fk_eva_performance_plan1 in _repository.Context.eva_performance_plan on m_eva_performance_plan_detail.performance_plan_id equals fk_eva_performance_plan1.id
|
||||
into eva_performance_planResult1
|
||||
from fk_eva_performance_planResult1 in eva_performance_planResult1.DefaultIfEmpty()
|
||||
|
||||
|
||||
where 1==1
|
||||
&& (m_eva_performance_plan_detail.performance_plan_id == model.performance_plan_id || !model.performance_plan_id.HasValue)
|
||||
|
||||
|
||||
orderby m_eva_performance_plan_detail.created descending
|
||||
select new eva_performance_plan_detailViewModel()
|
||||
{
|
||||
id = m_eva_performance_plan_detail.id,
|
||||
performance_plan_id = m_eva_performance_plan_detail.performance_plan_id,
|
||||
list_no = m_eva_performance_plan_detail.list_no,
|
||||
step = m_eva_performance_plan_detail.step,
|
||||
start_date = m_eva_performance_plan_detail.start_date,
|
||||
end_date = m_eva_performance_plan_detail.end_date,
|
||||
remark = m_eva_performance_plan_detail.remark,
|
||||
|
||||
performance_plan_id_eva_performance_plan_fiscal_year = fk_eva_performance_planResult1.fiscal_year,
|
||||
|
||||
isActive = m_eva_performance_plan_detail.isActive,
|
||||
Created = m_eva_performance_plan_detail.created,
|
||||
Updated = m_eva_performance_plan_detail.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
public eva_performance_plan_detailViewModel Insert(eva_performance_plan_detailInputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = Guid.NewGuid();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_performance_plan_detailViewModel Update(Guid id, eva_performance_plan_detailInputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.performance_plan_id = model.performance_plan_id;
|
||||
existingEntity.list_no = model.list_no;
|
||||
existingEntity.step = model.step;
|
||||
existingEntity.start_date = model.start_date;
|
||||
existingEntity.end_date = model.end_date;
|
||||
existingEntity.remark = model.remark;
|
||||
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_performance_plan_detailInputModel> 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.performance_plan_id = i.performance_plan_id;
|
||||
existingEntity.list_no = i.list_no;
|
||||
existingEntity.step = i.step;
|
||||
existingEntity.start_date = i.start_date;
|
||||
existingEntity.end_date = i.end_date;
|
||||
existingEntity.remark = i.remark;
|
||||
|
||||
|
||||
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
|
||||
}
|
||||
}
|
||||
else if (i.active_mode == "1" && !i.id.HasValue) // add
|
||||
{
|
||||
var entity = GetEntity(i);
|
||||
entity.id = Guid.NewGuid();
|
||||
_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_performance_plan_detailViewModel SetAsActive(Guid id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_performance_plan_detailViewModel SetAsInactive(Guid id)
|
||||
{
|
||||
var updated = _repository.SetAsInActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public void Delete(Guid id)
|
||||
{
|
||||
_repository.Delete(id);
|
||||
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Match Item
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -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_performance_plan_detailViewModel : BaseViewModel<Guid>
|
||||
{
|
||||
|
||||
public Guid? performance_plan_id { get; set; }
|
||||
|
||||
public int? list_no { get; set; }
|
||||
|
||||
public string step { get; set; }
|
||||
|
||||
public DateTime? start_date { get; set; }
|
||||
|
||||
public string txt_start_date { get { return MyHelper.GetDateStringForReport(this.start_date); } }
|
||||
|
||||
public DateTime? end_date { get; set; }
|
||||
|
||||
public string txt_end_date { get { return MyHelper.GetDateStringForReport(this.end_date); } }
|
||||
|
||||
public string remark { get; set; }
|
||||
|
||||
public int? performance_plan_id_eva_performance_plan_fiscal_year { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_performance_plan_detailWithSelectionViewModel: eva_performance_plan_detailViewModel
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user