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_performance_planService : IBaseService<Guid, eva_performance_planInputModel, eva_performance_planViewModel>
{
new eva_performance_planViewModel Insert(eva_performance_planInputModel model);
new eva_performance_planViewModel Update(Guid id, eva_performance_planInputModel model);
List<eva_performance_planViewModel> GetListByfiscal_year(int? fiscal_year);
List<eva_performance_planViewModel> GetListBySearch(eva_performance_planSearchModel model);
string UpdateMultiple(List<eva_performance_planInputModel> model);
eva_performance_planWithSelectionViewModel GetWithSelection(Guid id);
eva_performance_planWithSelectionViewModel GetBlankItem();
}
}

View File

@@ -0,0 +1,24 @@
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_planEntity : BaseEntity<Guid>
{
public int? fiscal_year { get; set; }
public int? theTime { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
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_planInputModel
{
public Guid? id { get; set; }
public int? fiscal_year { get; set; }
public int? theTime { 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_performance_planReportRequestModel : eva_performance_planSearchModel
{
public string filetype { get; set; }
public string contentType { get { return MyHelper.GetContentType(filetype); } }
}
}

View File

@@ -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_performance_planSearchModel
{
public int? fiscal_year { get; set; }
public int? theTime { get; set; }
}
}

View File

@@ -0,0 +1,258 @@
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_planService : Ieva_performance_planService
{
private IBaseRepository<eva_performance_planEntity, Guid> _repository;
private IMyDatabase db;
private Iexternal_linkageService ext;
public eva_performance_planService(IBaseRepository<eva_performance_planEntity, Guid> repository, IMyDatabase mydb, Iexternal_linkageService inext)
{
_repository = repository;
db = mydb;
ext = inext;
}
#region Private Functions
private eva_performance_planEntity GetEntity(eva_performance_planInputModel model)
{
return Mapper.Map<eva_performance_planEntity>(model);
}
private List<eva_performance_planEntity> GetEntityList(List<eva_performance_planInputModel> models)
{
return Mapper.Map<List<eva_performance_planEntity>>(models);
}
private eva_performance_planViewModel GetDto(eva_performance_planEntity entity)
{
return Mapper.Map<eva_performance_planViewModel>(entity);
}
private List<eva_performance_planViewModel> GetDtoList(List<eva_performance_planEntity> entities)
{
return Mapper.Map<List<eva_performance_planViewModel>>(entities);
}
private List<eva_performance_planEntity> GetListWithoutBase64Fields(IQueryable<eva_performance_planEntity> listQuery)
{
return listQuery.Select(c => new eva_performance_planEntity()
{
fiscal_year = c.fiscal_year,
theTime = c.theTime,
updated = c.updated,
id = c.id,
isActive = c.isActive
}).ToList();
}
#endregion
#region Public Functions
#region Query Functions
public eva_performance_planViewModel Get(Guid id)
{
var entity = _repository.Get(id);
return GetDto(entity);
}
public eva_performance_planWithSelectionViewModel GetWithSelection(Guid id)
{
var entity = _repository.Get(id);
var i = Mapper.Map<eva_performance_planWithSelectionViewModel>(entity);
return i;
}
public eva_performance_planWithSelectionViewModel GetBlankItem()
{
var i = new eva_performance_planWithSelectionViewModel();
return i;
}
public List<eva_performance_planViewModel> GetListALLeva_performance_plan()
{
var data = (
from m_eva_performance_plan in _repository.Context.eva_performance_plan
orderby m_eva_performance_plan.created descending
select new eva_performance_planViewModel()
{
id = m_eva_performance_plan.id,
fiscal_year = m_eva_performance_plan.fiscal_year,
theTime = m_eva_performance_plan.theTime,
isActive = m_eva_performance_plan.isActive,
Created = m_eva_performance_plan.created,
Updated = m_eva_performance_plan.updated
}
).Take(100).ToList();
return data;
}
public List<eva_performance_planViewModel> GetListByfiscal_year(int? fiscal_year)
{
var data = (
from m_eva_performance_plan in _repository.Context.eva_performance_plan
where m_eva_performance_plan.fiscal_year == fiscal_year || !fiscal_year.HasValue
orderby m_eva_performance_plan.created descending
select new eva_performance_planViewModel()
{
id = m_eva_performance_plan.id,
fiscal_year = m_eva_performance_plan.fiscal_year,
theTime = m_eva_performance_plan.theTime,
isActive = m_eva_performance_plan.isActive,
Created = m_eva_performance_plan.created,
Updated = m_eva_performance_plan.updated
}
).Take(100).ToList();
return data;
}
public List<eva_performance_planViewModel> GetListBySearch(eva_performance_planSearchModel model)
{
var data = (
from m_eva_performance_plan in _repository.Context.eva_performance_plan
where 1==1
&& (m_eva_performance_plan.fiscal_year == model.fiscal_year || !model.fiscal_year.HasValue)
&& (m_eva_performance_plan.theTime == model.theTime || !model.theTime.HasValue)
orderby m_eva_performance_plan.created descending
select new eva_performance_planViewModel()
{
id = m_eva_performance_plan.id,
fiscal_year = m_eva_performance_plan.fiscal_year,
theTime = m_eva_performance_plan.theTime,
isActive = m_eva_performance_plan.isActive,
Created = m_eva_performance_plan.created,
Updated = m_eva_performance_plan.updated
}
).Take(100).ToList();
return data;
}
#endregion
#region Manipulation Functions
public eva_performance_planViewModel Insert(eva_performance_planInputModel model)
{
var entity = GetEntity(model);
entity.id = Guid.NewGuid();
var inserted = _repository.Insert(entity);
return Get(inserted.id);
}
public eva_performance_planViewModel Update(Guid id, eva_performance_planInputModel model)
{
var existingEntity = _repository.Get(id);
if (existingEntity != null)
{
existingEntity.fiscal_year = model.fiscal_year;
existingEntity.theTime = model.theTime;
var updated = _repository.Update(id, existingEntity);
return Get(updated.id);
}
else
throw new NotificationException("No data to update");
}
public string UpdateMultiple(List<eva_performance_planInputModel> 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.theTime = i.theTime;
_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_planViewModel SetAsActive(Guid id)
{
var updated = _repository.SetAsActive(id);
return Get(updated.id);
}
public eva_performance_planViewModel 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
}
}

View File

@@ -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_performance_planViewModel : BaseViewModel<Guid>
{
public int? fiscal_year { get; set; }
public int? theTime { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace TodoAPI2.Models
{
public class eva_performance_planWithSelectionViewModel: eva_performance_planViewModel
{
}
}