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_create_evaluation_detail_summary2Service : IBaseService<int, eva_create_evaluation_detail_summary2InputModel, eva_create_evaluation_detail_summary2ViewModel>
|
||||
{
|
||||
new eva_create_evaluation_detail_summary2ViewModel Insert(eva_create_evaluation_detail_summary2InputModel model);
|
||||
new eva_create_evaluation_detail_summary2ViewModel Update(int id, eva_create_evaluation_detail_summary2InputModel model);
|
||||
List<eva_create_evaluation_detail_summary2ViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id);
|
||||
List<eva_create_evaluation_detail_summary2ViewModel> GetListBySearch(eva_create_evaluation_detail_summary2SearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_create_evaluation_detail_summary2InputModel> model);
|
||||
eva_create_evaluation_detail_summary2WithSelectionViewModel GetWithSelection(int id);
|
||||
eva_create_evaluation_detail_summary2WithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
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_create_evaluation_detail_summary2InputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public decimal? total_summary_supervisor { get; set; }
|
||||
|
||||
public decimal? Final_summary_supervisor { get; set; }
|
||||
|
||||
public decimal? total_summary_competency_supervisor { get; set; }
|
||||
|
||||
public decimal? Final_summary_competency_supervisor { get; set; }
|
||||
|
||||
public decimal? achievement_supervisor { get; set; }
|
||||
|
||||
public decimal? competency_supervisor { get; set; }
|
||||
|
||||
public decimal? score_supervisor { get; set; }
|
||||
|
||||
public string level_score_supervisor { 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_create_evaluation_detail_summary2ReportRequestModel : eva_create_evaluation_detail_summary2SearchModel
|
||||
{
|
||||
public string filetype { get; set; }
|
||||
|
||||
public string contentType { get { return MyHelper.GetContentType(filetype); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
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_create_evaluation_detail_summary2SearchModel
|
||||
{
|
||||
|
||||
public int id { get; set; }
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
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_create_evaluation_detail_summary2Service : Ieva_create_evaluation_detail_summary2Service
|
||||
{
|
||||
private IBaseRepository2<eva_create_evaluation_detailEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
|
||||
public eva_create_evaluation_detail_summary2Service(IBaseRepository2<eva_create_evaluation_detailEntity, int> repository, IMyDatabase mydb, Iexternal_linkageService inext)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_create_evaluation_detailEntity GetEntity(eva_create_evaluation_detail_summary2InputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detailEntity>(model);
|
||||
}
|
||||
private List<eva_create_evaluation_detailEntity> GetEntityList(List<eva_create_evaluation_detail_summary2InputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detailEntity>>(models);
|
||||
}
|
||||
private eva_create_evaluation_detail_summary2ViewModel GetDto(eva_create_evaluation_detailEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detail_summary2ViewModel>(entity);
|
||||
}
|
||||
private List<eva_create_evaluation_detail_summary2ViewModel> GetDtoList(List<eva_create_evaluation_detailEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detail_summary2ViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_create_evaluation_detail_summary2ViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_create_evaluation_detail_summary2WithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_create_evaluation_detail_summary2WithSelectionViewModel>(entity);
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_create_evaluation_detail_summary2WithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_create_evaluation_detail_summary2WithSelectionViewModel();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_summary2ViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id)
|
||||
{
|
||||
var model = new eva_create_evaluation_detail_summary2SearchModel();
|
||||
model.create_evaluation_id = create_evaluation_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_create_evaluation_detail_summary2ViewModel> GetListBySearch(eva_create_evaluation_detail_summary2SearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_create_evaluation_detail_summary2 in _repository.Context.eva_create_evaluation_detail
|
||||
|
||||
|
||||
where 1==1
|
||||
//&& (m_eva_create_evaluation_detail_summary2.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_create_evaluation_detail_summary2.create_evaluation_id == model.create_evaluation_id || !model.create_evaluation_id.HasValue)
|
||||
|
||||
|
||||
orderby m_eva_create_evaluation_detail_summary2.created descending
|
||||
select new eva_create_evaluation_detail_summary2ViewModel()
|
||||
{
|
||||
id = m_eva_create_evaluation_detail_summary2.id,
|
||||
create_evaluation_id = m_eva_create_evaluation_detail_summary2.create_evaluation_id,
|
||||
total_summary_supervisor = m_eva_create_evaluation_detail_summary2.total_summary_supervisor,
|
||||
Final_summary_supervisor = m_eva_create_evaluation_detail_summary2.Final_summary_supervisor,
|
||||
total_summary_competency_supervisor = m_eva_create_evaluation_detail_summary2.total_summary_competency_supervisor,
|
||||
Final_summary_competency_supervisor = m_eva_create_evaluation_detail_summary2.Final_summary_competency_supervisor,
|
||||
achievement_supervisor = m_eva_create_evaluation_detail_summary2.achievement_supervisor,
|
||||
competency_supervisor = m_eva_create_evaluation_detail_summary2.competency_supervisor,
|
||||
score_supervisor = m_eva_create_evaluation_detail_summary2.score_supervisor,
|
||||
level_score_supervisor = m_eva_create_evaluation_detail_summary2.level_score_supervisor,
|
||||
|
||||
|
||||
isActive = m_eva_create_evaluation_detail_summary2.isActive,
|
||||
Created = m_eva_create_evaluation_detail_summary2.created,
|
||||
Updated = m_eva_create_evaluation_detail_summary2.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
public int GetNewPrimaryKey()
|
||||
{
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_create_evaluation_detail
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if(x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
|
||||
return newkey.Value;
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detail_summary2ViewModel Insert(eva_create_evaluation_detail_summary2InputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_create_evaluation_detail_summary2ViewModel Update(int id, eva_create_evaluation_detail_summary2InputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.create_evaluation_id = model.create_evaluation_id;
|
||||
existingEntity.total_summary_supervisor = model.total_summary_supervisor;
|
||||
existingEntity.Final_summary_supervisor = model.Final_summary_supervisor;
|
||||
existingEntity.total_summary_competency_supervisor = model.total_summary_competency_supervisor;
|
||||
existingEntity.Final_summary_competency_supervisor = model.Final_summary_competency_supervisor;
|
||||
existingEntity.achievement_supervisor = model.achievement_supervisor;
|
||||
existingEntity.competency_supervisor = model.competency_supervisor;
|
||||
existingEntity.score_supervisor = model.score_supervisor;
|
||||
existingEntity.level_score_supervisor = model.level_score_supervisor;
|
||||
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_create_evaluation_detail_summary2InputModel> 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.create_evaluation_id = i.create_evaluation_id;
|
||||
existingEntity.total_summary_supervisor = i.total_summary_supervisor;
|
||||
existingEntity.Final_summary_supervisor = i.Final_summary_supervisor;
|
||||
existingEntity.total_summary_competency_supervisor = i.total_summary_competency_supervisor;
|
||||
existingEntity.Final_summary_competency_supervisor = i.Final_summary_competency_supervisor;
|
||||
existingEntity.achievement_supervisor = i.achievement_supervisor;
|
||||
existingEntity.competency_supervisor = i.competency_supervisor;
|
||||
existingEntity.score_supervisor = i.score_supervisor;
|
||||
existingEntity.level_score_supervisor = i.level_score_supervisor;
|
||||
|
||||
|
||||
_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_create_evaluation_detail_summary2ViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_create_evaluation_detail_summary2ViewModel 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,37 @@
|
||||
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_create_evaluation_detail_summary2ViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? create_evaluation_id { get; set; }
|
||||
|
||||
public decimal? total_summary_supervisor { get; set; }
|
||||
|
||||
public decimal? Final_summary_supervisor { get; set; }
|
||||
|
||||
public decimal? total_summary_competency_supervisor { get; set; }
|
||||
|
||||
public decimal? Final_summary_competency_supervisor { get; set; }
|
||||
|
||||
public decimal? achievement_supervisor { get; set; }
|
||||
|
||||
public decimal? competency_supervisor { get; set; }
|
||||
|
||||
public decimal? score_supervisor { get; set; }
|
||||
|
||||
public string level_score_supervisor { 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_create_evaluation_detail_summary2WithSelectionViewModel: eva_create_evaluation_detail_summary2ViewModel
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user