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_evaluation_behavior_process2Service : IBaseService<int, eva_evaluation_behavior_process2InputModel, eva_evaluation_behavior_process2ViewModel>
|
||||
{
|
||||
new eva_evaluation_behavior_process2ViewModel Insert(eva_evaluation_behavior_process2InputModel model);
|
||||
new eva_evaluation_behavior_process2ViewModel Update(int id, eva_evaluation_behavior_process2InputModel model);
|
||||
List<eva_evaluation_behavior_process2ViewModel> GetListBycreate_evaluation_detail_id(int? create_evaluation_detail_id);
|
||||
List<eva_evaluation_behavior_process2ViewModel> GetListBySearch(eva_evaluation_behavior_process2SearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_evaluation_behavior_process2InputModel> model);
|
||||
eva_evaluation_behavior_process2WithSelectionViewModel GetWithSelection(int id);
|
||||
eva_evaluation_behavior_process2WithSelectionViewModel GetBlankItem();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_evaluation_behavior_process2InputModel
|
||||
{
|
||||
|
||||
public int? id { get; set; }
|
||||
|
||||
public int? create_evaluation_detail_id { get; set; }
|
||||
|
||||
public string behavior { get; set; }
|
||||
|
||||
public decimal? weight { get; set; }
|
||||
|
||||
public decimal? score { get; set; }
|
||||
|
||||
public decimal? score2 { get; set; }
|
||||
|
||||
public decimal? sumary2 { get; set; }
|
||||
|
||||
public string target_score1 { get; set; }
|
||||
|
||||
public string target_score2 { get; set; }
|
||||
|
||||
public string target_score3 { get; set; }
|
||||
|
||||
public string target_score4 { get; set; }
|
||||
|
||||
public string target_score5 { 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_evaluation_behavior_process2ReportRequestModel : eva_evaluation_behavior_process2SearchModel
|
||||
{
|
||||
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_evaluation_behavior_process2SearchModel
|
||||
{
|
||||
|
||||
public int id { get; set; }
|
||||
|
||||
public int? create_evaluation_detail_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
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_evaluation_behavior_process2Service : Ieva_evaluation_behavior_process2Service
|
||||
{
|
||||
private IBaseRepository2<eva_evaluation_behaviorEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
|
||||
public eva_evaluation_behavior_process2Service(IBaseRepository2<eva_evaluation_behaviorEntity, int> repository, IMyDatabase mydb, Iexternal_linkageService inext)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_evaluation_behaviorEntity GetEntity(eva_evaluation_behavior_process2InputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_evaluation_behaviorEntity>(model);
|
||||
}
|
||||
private List<eva_evaluation_behaviorEntity> GetEntityList(List<eva_evaluation_behavior_process2InputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_evaluation_behaviorEntity>>(models);
|
||||
}
|
||||
private eva_evaluation_behavior_process2ViewModel GetDto(eva_evaluation_behaviorEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_evaluation_behavior_process2ViewModel>(entity);
|
||||
}
|
||||
private List<eva_evaluation_behavior_process2ViewModel> GetDtoList(List<eva_evaluation_behaviorEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_evaluation_behavior_process2ViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_evaluation_behavior_process2ViewModel Get(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
public eva_evaluation_behavior_process2WithSelectionViewModel GetWithSelection(int id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_evaluation_behavior_process2WithSelectionViewModel>(entity);
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_evaluation_behavior_process2WithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_evaluation_behavior_process2WithSelectionViewModel();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_evaluation_behavior_process2ViewModel> GetListBycreate_evaluation_detail_id(int? create_evaluation_detail_id)
|
||||
{
|
||||
var model = new eva_evaluation_behavior_process2SearchModel();
|
||||
model.create_evaluation_detail_id = create_evaluation_detail_id;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_evaluation_behavior_process2ViewModel> GetListBySearch(eva_evaluation_behavior_process2SearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_evaluation_behavior_process2 in _repository.Context.eva_evaluation_behavior
|
||||
|
||||
join fk_eva_create_evaluation_detail1 in _repository.Context.eva_create_evaluation_detail on m_eva_evaluation_behavior_process2.create_evaluation_detail_id equals fk_eva_create_evaluation_detail1.id
|
||||
into eva_create_evaluation_detailResult1
|
||||
from fk_eva_create_evaluation_detailResult1 in eva_create_evaluation_detailResult1.DefaultIfEmpty()
|
||||
|
||||
|
||||
where 1==1
|
||||
//&& (m_eva_evaluation_behavior_process2.id == model.id || !model.id.HasValue)
|
||||
&& (m_eva_evaluation_behavior_process2.create_evaluation_detail_id == model.create_evaluation_detail_id || !model.create_evaluation_detail_id.HasValue)
|
||||
|
||||
|
||||
orderby m_eva_evaluation_behavior_process2.created descending
|
||||
select new eva_evaluation_behavior_process2ViewModel()
|
||||
{
|
||||
id = m_eva_evaluation_behavior_process2.id,
|
||||
create_evaluation_detail_id = m_eva_evaluation_behavior_process2.create_evaluation_detail_id,
|
||||
behavior = m_eva_evaluation_behavior_process2.behavior,
|
||||
weight = m_eva_evaluation_behavior_process2.weight,
|
||||
score = m_eva_evaluation_behavior_process2.score,
|
||||
score2 = m_eva_evaluation_behavior_process2.score2,
|
||||
sumary2 = m_eva_evaluation_behavior_process2.sumary2,
|
||||
target_score1 = m_eva_evaluation_behavior_process2.target_score1,
|
||||
target_score2 = m_eva_evaluation_behavior_process2.target_score2,
|
||||
target_score3 = m_eva_evaluation_behavior_process2.target_score3,
|
||||
target_score4 = m_eva_evaluation_behavior_process2.target_score4,
|
||||
target_score5 = m_eva_evaluation_behavior_process2.target_score5,
|
||||
|
||||
create_evaluation_detail_id_eva_create_evaluation_detail_create_evaluation_id = fk_eva_create_evaluation_detailResult1.create_evaluation_id,
|
||||
|
||||
isActive = m_eva_evaluation_behavior_process2.isActive,
|
||||
Created = m_eva_evaluation_behavior_process2.created,
|
||||
Updated = m_eva_evaluation_behavior_process2.updated
|
||||
}
|
||||
).Take(100).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
public int GetNewPrimaryKey()
|
||||
{
|
||||
int? newkey = 0;
|
||||
|
||||
var x = (from i in _repository.Context.eva_evaluation_behavior
|
||||
orderby i.id descending
|
||||
select i).Take(1).ToList();
|
||||
|
||||
if(x.Count > 0)
|
||||
{
|
||||
newkey = x[0].id + 1;
|
||||
}
|
||||
|
||||
return newkey.Value;
|
||||
}
|
||||
|
||||
public eva_evaluation_behavior_process2ViewModel Insert(eva_evaluation_behavior_process2InputModel model)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = GetNewPrimaryKey();
|
||||
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
public eva_evaluation_behavior_process2ViewModel Update(int id, eva_evaluation_behavior_process2InputModel model)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
//existingEntity.create_evaluation_detail_id = model.create_evaluation_detail_id;
|
||||
//existingEntity.behavior = model.behavior;
|
||||
//existingEntity.weight = model.weight;
|
||||
//existingEntity.score = model.score;
|
||||
existingEntity.score2 = model.score2;
|
||||
existingEntity.sumary2 = model.sumary2;
|
||||
//existingEntity.target_score1 = model.target_score1;
|
||||
//existingEntity.target_score2 = model.target_score2;
|
||||
//existingEntity.target_score3 = model.target_score3;
|
||||
//existingEntity.target_score4 = model.target_score4;
|
||||
//existingEntity.target_score5 = model.target_score5;
|
||||
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_evaluation_behavior_process2InputModel> 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_detail_id = i.create_evaluation_detail_id;
|
||||
//existingEntity.behavior = i.behavior;
|
||||
//existingEntity.weight = i.weight;
|
||||
//existingEntity.score = i.score;
|
||||
existingEntity.score2 = i.score2;
|
||||
existingEntity.sumary2 = i.sumary2;
|
||||
//existingEntity.target_score1 = i.target_score1;
|
||||
//existingEntity.target_score2 = i.target_score2;
|
||||
//existingEntity.target_score3 = i.target_score3;
|
||||
//existingEntity.target_score4 = i.target_score4;
|
||||
//existingEntity.target_score5 = i.target_score5;
|
||||
|
||||
|
||||
_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_evaluation_behavior_process2ViewModel SetAsActive(int id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_evaluation_behavior_process2ViewModel 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,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_evaluation_behavior_process2ViewModel : BaseViewModel2<int>
|
||||
{
|
||||
|
||||
public int? create_evaluation_detail_id { get; set; }
|
||||
|
||||
public string behavior { get; set; }
|
||||
|
||||
public decimal? weight { get; set; }
|
||||
|
||||
public decimal? score { get; set; }
|
||||
|
||||
public decimal? score2 { get; set; }
|
||||
|
||||
public decimal? sumary2 { get; set; }
|
||||
|
||||
public string target_score1 { get; set; }
|
||||
|
||||
public string target_score2 { get; set; }
|
||||
|
||||
public string target_score3 { get; set; }
|
||||
|
||||
public string target_score4 { get; set; }
|
||||
|
||||
public string target_score5 { get; set; }
|
||||
|
||||
public int? create_evaluation_detail_id_eva_create_evaluation_detail_create_evaluation_id { 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_evaluation_behavior_process2WithSelectionViewModel: eva_evaluation_behavior_process2ViewModel
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user