From 3b8d643eca1845bab8f126d05a9d01aab695a195 Mon Sep 17 00:00:00 2001 From: nakorn Date: Tue, 19 Oct 2021 20:41:43 +0700 Subject: [PATCH] Add level score detail --- .../eva_level_score_detailControllers.cs | 403 ++++++++++++++++++ EF/DataContext.cs | 2 +- EXCEL/eva_level_score_detail.xlsx | Bin 0 -> 10414 bytes .../Ieva_level_score_detailService.cs | 32 ++ .../eva_level_score_detailEntity.cs | 43 ++ .../eva_level_score_detailInputModel.cs | 32 ++ ...va_level_score_detailReportRequestModel.cs | 21 + .../eva_level_score_detailSearchModel.cs | 23 + .../eva_level_score_detailService.cs | 288 +++++++++++++ .../eva_level_score_detailViewModel.cs | 30 ++ ...evel_score_detailWithSelectionViewModel.cs | 12 + Startup.cs | 6 + .../eva_level_score_d.cshtml | 116 ++++- .../eva_level_score_detail.cshtml | 122 ++++++ tb320eva.csproj | 2 + tb320eva.xml | 118 +++++ .../eva_level_score_detail.js | 227 ++++++++++ 17 files changed, 1462 insertions(+), 15 deletions(-) create mode 100644 ApiControllers/eva_level_score_detailControllers.cs create mode 100644 EXCEL/eva_level_score_detail.xlsx create mode 100644 Models/eva_level_score_detail/Ieva_level_score_detailService.cs create mode 100644 Models/eva_level_score_detail/eva_level_score_detailEntity.cs create mode 100644 Models/eva_level_score_detail/eva_level_score_detailInputModel.cs create mode 100644 Models/eva_level_score_detail/eva_level_score_detailReportRequestModel.cs create mode 100644 Models/eva_level_score_detail/eva_level_score_detailSearchModel.cs create mode 100644 Models/eva_level_score_detail/eva_level_score_detailService.cs create mode 100644 Models/eva_level_score_detail/eva_level_score_detailViewModel.cs create mode 100644 Models/eva_level_score_detail/eva_level_score_detailWithSelectionViewModel.cs create mode 100644 Views/eva_level_score_detailView/eva_level_score_detail.cshtml create mode 100644 wwwroot/js/eva_level_score_detail/eva_level_score_detail.js diff --git a/ApiControllers/eva_level_score_detailControllers.cs b/ApiControllers/eva_level_score_detailControllers.cs new file mode 100644 index 0000000..eb4368d --- /dev/null +++ b/ApiControllers/eva_level_score_detailControllers.cs @@ -0,0 +1,403 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.Extensions.Logging; +using TTSW.Controllers; +using TTSW.EF; +using TTSW.Utils; +using TTSW.Constant; +using TTSW.Common; +using TodoAPI2.Models; +using System.Data; +using Microsoft.Extensions.Configuration; +using System.IO; +using System.Net; + +namespace TodoAPI2.Controllers +{ + //[Authorize] + [Produces("application/json")] + [Route("api/eva_level_score_detail")] + public class eva_level_score_detailController : BaseController + { + #region Private Variables + private ILogger _logger; + private Ieva_level_score_detailService _repository; + private IConfiguration Configuration { get; set; } + #endregion + + #region Properties + + #endregion + + /// + /// Default constructure for dependency injection + /// + /// + /// + /// + public eva_level_score_detailController(ILogger logger, Ieva_level_score_detailService repository, IConfiguration configuration) + { + _logger = logger; + _repository = repository; + Configuration = configuration; + } + + /// + /// Get specific item by id + /// + /// + /// + /// Return Get specific item by id + /// Returns the item + /// Error Occurred + [HttpGet("{id}")] + [ProducesResponseType(typeof(eva_level_score_detailWithSelectionViewModel), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult Get(Guid id) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + var result = _repository.GetWithSelection(id); + + return Ok(result); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception in IActionResult Get.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + /// + /// Get Blank Item + /// + /// + /// + /// Return a blank item + /// Returns the item + /// Error Occurred + [HttpGet("GetBlankItem")] + [ProducesResponseType(typeof(eva_level_score_detailWithSelectionViewModel), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult GetBlankItem() + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + var result = _repository.GetBlankItem(); + + return Ok(result); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception in IActionResult GetBlankItem.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + /// + /// Get list items by level_score_id + /// + /// + /// + /// Return list of items by specifced keyword + /// Returns the item + /// Error Occurred + [HttpGet("")] + [ProducesResponseType(typeof(List), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult GetList(Guid level_score_id) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + return Ok(_repository.GetListBylevel_score_id(level_score_id)); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception in IActionResult GetList.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + /// + /// Get list items by search + /// + /// + /// + /// Return list of items by specifced keyword + /// Returns the item + /// Error Occurred + [HttpGet("GetListBySearch")] + [ProducesResponseType(typeof(List), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult GetListBySearch(eva_level_score_detailSearchModel model) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + return Ok(_repository.GetListBySearch(model)); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception in IActionResult GetListBySearch.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + /// + /// Download Report + /// + /// + /// + /// Return list of items by specifced keyword + /// Returns the item + /// Error Occurred + [HttpGet("eva_level_score_detail_report")] + [ProducesResponseType(typeof(FileStreamResult), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult eva_level_score_detail_report(eva_level_score_detailReportRequestModel model) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + var httpclient = new WebClient(); + string mainurl = MyHelper.GetConfig(Configuration, "JasperReportServer:MainURL"); + string reportsite = MyHelper.GetConfig(Configuration, "JasperReportServer:reportsite"); + string username = MyHelper.GetConfig(Configuration, "JasperReportServer:username"); + string password = MyHelper.GetConfig(Configuration, "JasperReportServer:password"); + + string url = $"{mainurl}{reportsite}/xxใส่ชื่อรายงานตรงนี้xx.{model.filetype}?{MyHelper.GetParameterForJasperReport(model)}&j_username={username}&j_password={password}"; + + if (model.filetype == "xlsx") + { + url += "&ignorePagination=true"; + } + + var data = httpclient.DownloadData(url); + var stream = new MemoryStream(data); + + return File(stream, model.contentType); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while GetReport.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + /// + /// Create new item + /// + /// + /// + /// + /// Response Result Message + /// Response Result Message + /// If the model is invalid + /// Error Occurred + [HttpPost("")] + [ProducesResponseType(typeof(CommonResponseMessage), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult Insert([FromBody] eva_level_score_detailInputModel model) + { + if (ModelState.IsValid) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + var result = _repository.Insert(model, true); + var message = new CommonResponseMessage(); + message.code = "200"; + message.message = $"เพิ่มข้อมูล เรียบร้อย"; + message.data = result; + return Ok(message); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while insert.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + return BadRequest(ModelState); + } + + /// + /// Update item + /// + /// + /// + /// + /// + /// Response Result Message + /// Response Result Message + /// If the model is invalid + /// Error Occurred + [HttpPut("{id}")] + [ProducesResponseType(typeof(CommonResponseMessage), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult Update(Guid id, [FromBody] eva_level_score_detailInputModel model) + { + if (ModelState.IsValid) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + var result = _repository.Update(id, model, true); + var message = new CommonResponseMessage(); + message.code = "200"; + message.message = $"แก้ไขข้อมูล เรียบร้อย"; + message.data = result; + return Ok(message); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while update {id.ToString()}.", ex); + return StatusCode(500, $"{id.ToString()}. {ex.Message}"); + } + } + + return BadRequest(ModelState); + } + + /// + /// Delete item + /// + /// + /// + /// + /// Response Result Message + /// Response Result Message + /// If the model is invalid + /// Error Occurred + [HttpDelete("{id}")] + [ProducesResponseType(typeof(CommonResponseMessage), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult Delete(Guid id) + { + if (ModelState.IsValid) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + _repository.Delete(id); + var message = new CommonResponseMessage(); + message.code = "200"; + message.message = $"ลบข้อมูล เรียบร้อย"; + message.data = null; + return Ok(message); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while delete {id.ToString()}.", ex); + return StatusCode(500, $"{id.ToString()}. {ex.Message}"); + } + } + + return BadRequest(ModelState); + } + + /// + /// Update multiple item + /// + /// + /// + /// + /// Response Result Message + /// Response Result Message + /// If the model is invalid + /// Error Occurred + [HttpPut("UpdateMultiple")] + [ProducesResponseType(typeof(CommonResponseMessage), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult UpdateMultiple([FromBody] List model) + { + if (ModelState.IsValid) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + string rowCount = _repository.UpdateMultiple(model, true); + var message = new CommonResponseMessage(); + message.code = "200"; + message.message = "ปรับปรุงข้อมูลเรียบร้อย จำนวน "+rowCount+" รายการ"; + message.data = null; + return Ok(message); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while UpdateMultiple.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + return BadRequest(ModelState); + } + + /// + /// Refresh AutoField of all items + /// + /// + /// + /// Response Result Message + /// Response Result Message + /// If the model is invalid + /// Error Occurred + [HttpPut("RefreshAutoField")] + [ProducesResponseType(typeof(CommonResponseMessage), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult RefreshAutoField() + { + if (ModelState.IsValid) + { + try + { + //if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + _repository.RefreshAutoFieldOfAllData(); + var message = new CommonResponseMessage(); + message.code = "200"; + message.message = $"ปรับปรุง Auto Field ของทุก record เรียบร้อย"; + message.data = null; + return Ok(message); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while RefreshAutoField.", ex); + return StatusCode(500, $"มีปัญหาระหว่างการปรับปรุง Auto Field. {ex.Message}"); + } + } + + return BadRequest(ModelState); + } + + + + } +} diff --git a/EF/DataContext.cs b/EF/DataContext.cs index 99c4dd0..6f72bd0 100644 --- a/EF/DataContext.cs +++ b/EF/DataContext.cs @@ -46,7 +46,7 @@ namespace TTSW.EF { public DbSet eva_evaluation_achievement_attach { get; set; } public DbSet activity_log_eva { get; set; } public DbSet eva_setup_permission { get; set; } - + public DbSet eva_level_score_detail { get; set; } protected override void OnModelCreating (ModelBuilder modelBuilder) { base.OnModelCreating (modelBuilder); diff --git a/EXCEL/eva_level_score_detail.xlsx b/EXCEL/eva_level_score_detail.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..ab9c57fa23cc0aa1b593bc61cdb6467a6855ef63 GIT binary patch literal 10414 zcmeHtg;yNe_I2ZKfgr&hg1ZKHcPD7$PGiAc6C}6?3mV*Af+u*;hF}TquD{OAyl-Zh z`Tm0Us@JMo)m3M&s#|BDbM8J@MIHtg2LKO11ONc!08yTxF$X9B02U4azy=^f>x(-& zfPfAlBMmPnpsOLXr@b9n9xOCnE&v*G|NplC;t?p<7;@-g#cbE!5tiuCiu@2>T8c>2 zLZnZ%g^=o*phMNLNkDh!OKYL3S&i6Dt!g)>Pjf1WU$H==D<-mT$9$u!Ol6Gn@ok06 z@vD289Lb=9a;>+uanW44_-KcR@Kf~&3QY^9%r+E{6x6s}b;uk)yHAw1#mXXt#i`q0 z{wRgMp4)vj)T0Y6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rm#)z->R0Upnp&Ge?kHP>|_AIKN9~_^S=k`zna%l{Kfo_u&p8w2k}7w Q02T71fw-{?^{=!41Jc0*8UO$Q literal 0 HcmV?d00001 diff --git a/Models/eva_level_score_detail/Ieva_level_score_detailService.cs b/Models/eva_level_score_detail/Ieva_level_score_detailService.cs new file mode 100644 index 0000000..f1aee1e --- /dev/null +++ b/Models/eva_level_score_detail/Ieva_level_score_detailService.cs @@ -0,0 +1,32 @@ +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_level_score_detailService : IBaseService2 + { + new eva_level_score_detailViewModel Insert(eva_level_score_detailInputModel model, bool is_force_save); + new eva_level_score_detailViewModel Update(Guid id, eva_level_score_detailInputModel model, bool is_force_save); + List GetListBylevel_score_id(Guid level_score_id); + List GetListBySearch(eva_level_score_detailSearchModel model); + + string UpdateMultiple(List model, bool is_force_save); + eva_level_score_detailWithSelectionViewModel GetWithSelection(Guid id); + eva_level_score_detailWithSelectionViewModel GetBlankItem(); + + void RefreshAutoFieldOfAllData(); + eva_level_score_detailEntity GetEntity(Guid id); + DataContext GetContext(); + + + + } +} + diff --git a/Models/eva_level_score_detail/eva_level_score_detailEntity.cs b/Models/eva_level_score_detail/eva_level_score_detailEntity.cs new file mode 100644 index 0000000..12e8345 --- /dev/null +++ b/Models/eva_level_score_detail/eva_level_score_detailEntity.cs @@ -0,0 +1,43 @@ +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_level_score_detailEntity : BaseEntity2 + { + + + [ForeignKey("level_score_id")] + public eva_level_scoreEntity eva_level_score_level_score_id { get; set; } + public Guid level_score_id { get; set; } + + public decimal? min_value { get; set; } + + public decimal? max_value { get; set; } + + public decimal? min_percentage { get; set; } + + public decimal? max_percentage { get; set; } + + + public void SetAutoField(DataContext context) + { + + } + + public void DoAfterInsertUpdate(DataContext context) + { + + } + + } +} diff --git a/Models/eva_level_score_detail/eva_level_score_detailInputModel.cs b/Models/eva_level_score_detail/eva_level_score_detailInputModel.cs new file mode 100644 index 0000000..e628bfb --- /dev/null +++ b/Models/eva_level_score_detail/eva_level_score_detailInputModel.cs @@ -0,0 +1,32 @@ +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_level_score_detailInputModel + { + + public Guid? id { get; set; } + + public Guid level_score_id { get; set; } + + public decimal? min_value { get; set; } + + public decimal? max_value { get; set; } + + public decimal? min_percentage { get; set; } + + public decimal? max_percentage { get; set; } + + public string active_mode { get; set; } + } +} + diff --git a/Models/eva_level_score_detail/eva_level_score_detailReportRequestModel.cs b/Models/eva_level_score_detail/eva_level_score_detailReportRequestModel.cs new file mode 100644 index 0000000..84587aa --- /dev/null +++ b/Models/eva_level_score_detail/eva_level_score_detailReportRequestModel.cs @@ -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_level_score_detailReportRequestModel : eva_level_score_detailSearchModel + { + public string filetype { get; set; } + + public string contentType { get { return MyHelper.GetContentType(filetype); } } + } +} + diff --git a/Models/eva_level_score_detail/eva_level_score_detailSearchModel.cs b/Models/eva_level_score_detail/eva_level_score_detailSearchModel.cs new file mode 100644 index 0000000..d6970b8 --- /dev/null +++ b/Models/eva_level_score_detail/eva_level_score_detailSearchModel.cs @@ -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_level_score_detailSearchModel + { + + public Guid id { get; set; } + + public Guid level_score_id { get; set; } + + } +} + diff --git a/Models/eva_level_score_detail/eva_level_score_detailService.cs b/Models/eva_level_score_detail/eva_level_score_detailService.cs new file mode 100644 index 0000000..35868dc --- /dev/null +++ b/Models/eva_level_score_detail/eva_level_score_detailService.cs @@ -0,0 +1,288 @@ +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_level_score_detailService : Ieva_level_score_detailService + { + private IBaseRepository2 _repository; + private IMyDatabase db; + private Iexternal_linkageService ext; + + public eva_level_score_detailService(IBaseRepository2 repository, IMyDatabase mydb, Iexternal_linkageService inext) + { + _repository = repository; + db = mydb; + ext = inext; + } + + #region Private Functions + private eva_level_score_detailEntity GetEntity(eva_level_score_detailInputModel model) + { + return Mapper.Map(model); + } + private List GetEntityList(List models) + { + return Mapper.Map>(models); + } + private eva_level_score_detailViewModel GetDto(eva_level_score_detailEntity entity) + { + return Mapper.Map(entity); + } + private List GetDtoList(List entities) + { + return Mapper.Map>(entities); + } + + #endregion + + #region Public Functions + #region Query Functions + + public eva_level_score_detailViewModel Get(Guid id) + { + var entity = _repository.Get(id); + + return GetDto(entity); + } + + public eva_level_score_detailEntity GetEntity(Guid id) + { + var entity = _repository.Get(id); + + return entity; + } + + public DataContext GetContext() + { + return _repository.Context; + } + + public eva_level_score_detailWithSelectionViewModel GetWithSelection(Guid id) + { + var entity = _repository.Get(id); + var i = Mapper.Map(entity); + + + return i; + } + public eva_level_score_detailWithSelectionViewModel GetBlankItem() + { + var i = new eva_level_score_detailWithSelectionViewModel(); + + + return i; + } + + public List GetListBylevel_score_id(Guid level_score_id) + { + var model = new eva_level_score_detailSearchModel(); + model.level_score_id = level_score_id; + return GetListBySearch(model); + } + + public List GetListBySearch(eva_level_score_detailSearchModel model) + { + var data = ( + from m_eva_level_score_detail in _repository.Context.eva_level_score_detail + + join fk_eva_level_score1 in _repository.Context.eva_level_score on m_eva_level_score_detail.level_score_id equals fk_eva_level_score1.id + into eva_level_scoreResult1 + from fk_eva_level_scoreResult1 in eva_level_scoreResult1.DefaultIfEmpty() + + + where + 1 == 1 + && (m_eva_level_score_detail.level_score_id == model.level_score_id) + + + orderby m_eva_level_score_detail.created descending + select new eva_level_score_detailViewModel() + { + id = m_eva_level_score_detail.id, + level_score_id = m_eva_level_score_detail.level_score_id, + min_value = m_eva_level_score_detail.min_value, + max_value = m_eva_level_score_detail.max_value, + min_percentage = m_eva_level_score_detail.min_percentage, + max_percentage = m_eva_level_score_detail.max_percentage, + + level_score_id_eva_level_score_code = fk_eva_level_scoreResult1.code, + + isActive = m_eva_level_score_detail.isActive, + Created = m_eva_level_score_detail.created, + Updated = m_eva_level_score_detail.updated + } + ).Take(1000).ToList(); + + return data; + } + + #endregion + + #region Manipulation Functions + + + + public eva_level_score_detailViewModel Insert(eva_level_score_detailInputModel model, bool is_force_save) + { + var entity = GetEntity(model); + entity.id = Guid.NewGuid(); + + + entity.SetAutoField(_repository.Context); + + if (is_force_save) + { + var inserted = _repository.Insert(entity); + entity.DoAfterInsertUpdate(_repository.Context); + return Get(inserted.id); + } + else + { + _repository.InsertWithoutCommit(entity); + entity.DoAfterInsertUpdate(_repository.Context); + return Mapper.Map(entity); + } + } + + public eva_level_score_detailViewModel Update(Guid id, eva_level_score_detailInputModel model, bool is_force_save) + { + var existingEntity = _repository.Get(id); + if (existingEntity != null) + { + existingEntity.level_score_id = model.level_score_id; + existingEntity.min_value = model.min_value; + existingEntity.max_value = model.max_value; + existingEntity.min_percentage = model.min_percentage; + existingEntity.max_percentage = model.max_percentage; + + existingEntity.SetAutoField(_repository.Context); + + if (is_force_save) + { + var updated = _repository.Update(id, existingEntity); + existingEntity.DoAfterInsertUpdate(_repository.Context); + return Get(updated.id); + } + else + { + _repository.UpdateWithoutCommit(id, existingEntity); + existingEntity.DoAfterInsertUpdate(_repository.Context); + return Mapper.Map(existingEntity); + } + } + else + throw new NotificationException("No data to update"); + } + + public string UpdateMultiple(List model, bool is_force_save) + { + 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.level_score_id = i.level_score_id; + existingEntity.min_value = i.min_value; + existingEntity.max_value = i.max_value; + existingEntity.min_percentage = i.min_percentage; + existingEntity.max_percentage = i.max_percentage; + + existingEntity.SetAutoField(_repository.Context); + _repository.UpdateWithoutCommit(i.id.Value, existingEntity); + } + } + else if (i.active_mode == "1" && !i.id.HasValue) // add + { + var entity = GetEntity(i); + entity.id = Guid.NewGuid(); + entity.SetAutoField(_repository.Context); + _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 + } + } + if (is_force_save) + { + _repository.Context.SaveChanges(); + } + + return model.Count().ToString(); + } + + public eva_level_score_detailViewModel SetAsActive(Guid id) + { + var updated = _repository.SetAsActive(id); + + return Get(updated.id); + } + public eva_level_score_detailViewModel SetAsInactive(Guid id) + { + var updated = _repository.SetAsInActive(id); + + return Get(updated.id); + } + public void Delete(Guid id) + { + _repository.Delete(id); + + return; + } + + public void RefreshAutoFieldOfAllData() + { + var all_items = from i in _repository.Context.eva_level_score_detail + select i; + foreach (var item in all_items) + { + item.SetAutoField(_repository.Context); + } + _repository.Context.SaveChanges(); + } + + private Dictionary GetLookupForLog() + { + var i = new Dictionary(); + + + i.Add("level_score_id", "level_score_id"); + i.Add("level_score_id_eva_level_score_code", "level_score_id"); + i.Add("min_value", "ช่วงคะแนนต่ำสุด"); + i.Add("max_value", "ช่วงคะแนนสูงสุด"); + i.Add("min_percentage", "ร้อยละที่ได้เลื่อนต่ำสุด"); + i.Add("max_percentage", "ร้อยละที่ได้เลื่อนสูงสุด"); + + return i; + } + + #endregion + + #region Match Item + + #endregion + + #endregion + } +} \ No newline at end of file diff --git a/Models/eva_level_score_detail/eva_level_score_detailViewModel.cs b/Models/eva_level_score_detail/eva_level_score_detailViewModel.cs new file mode 100644 index 0000000..00c6daa --- /dev/null +++ b/Models/eva_level_score_detail/eva_level_score_detailViewModel.cs @@ -0,0 +1,30 @@ +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_level_score_detailViewModel : BaseViewModel2 + { + + public Guid level_score_id { get; set; } + + public decimal? min_value { get; set; } + + public decimal? max_value { get; set; } + + public decimal? min_percentage { get; set; } + + public decimal? max_percentage { get; set; } + + public string level_score_id_eva_level_score_code { get; set; } + + } +} \ No newline at end of file diff --git a/Models/eva_level_score_detail/eva_level_score_detailWithSelectionViewModel.cs b/Models/eva_level_score_detail/eva_level_score_detailWithSelectionViewModel.cs new file mode 100644 index 0000000..ccc6296 --- /dev/null +++ b/Models/eva_level_score_detail/eva_level_score_detailWithSelectionViewModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace TodoAPI2.Models +{ + public class eva_level_score_detailWithSelectionViewModel: eva_level_score_detailViewModel + { + + } +} \ No newline at end of file diff --git a/Startup.cs b/Startup.cs index f84face..1f47a9f 100644 --- a/Startup.cs +++ b/Startup.cs @@ -340,6 +340,9 @@ namespace Test01 services.AddScoped, BaseRepository2>(); services.AddScoped(); + services.AddScoped, BaseRepository2>(); + services.AddScoped(); + #endregion services.TryAddSingleton(); @@ -643,6 +646,9 @@ namespace Test01 cfg.CreateMap(); cfg.CreateMap(); + cfg.CreateMap(); + cfg.CreateMap(); + cfg.CreateMap(); }); #endregion diff --git a/Views/eva_level_scoreView/eva_level_score_d.cshtml b/Views/eva_level_scoreView/eva_level_score_d.cshtml index 9b847c5..b3806fc 100644 --- a/Views/eva_level_scoreView/eva_level_score_d.cshtml +++ b/Views/eva_level_scoreView/eva_level_score_d.cshtml @@ -5,6 +5,59 @@ Layout = "_LayoutDirect"; } + +