5799 lines
265 KiB
C#
5799 lines
265 KiB
C#
using BMA.EHR.Application.Messaging;
|
|
using BMA.EHR.Application.Repositories;
|
|
using BMA.EHR.Application.Repositories.Commands;
|
|
using BMA.EHR.Application.Requests.Commands;
|
|
using BMA.EHR.Application.Responses;
|
|
using BMA.EHR.Command.Service.Requests;
|
|
using BMA.EHR.Command.Service.Responses;
|
|
using BMA.EHR.Domain.Common;
|
|
using BMA.EHR.Domain.Extensions;
|
|
using BMA.EHR.Domain.Models.Commands.Core;
|
|
using BMA.EHR.Domain.Shared;
|
|
using BMA.EHR.Infrastructure.Persistence;
|
|
using iTextSharp.text;
|
|
using iTextSharp.text.pdf;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Newtonsoft.Json;
|
|
using Swashbuckle.AspNetCore.Annotations;
|
|
using System.Net;
|
|
using System.Net.Http.Headers;
|
|
using System.Security.Claims;
|
|
|
|
namespace BMA.EHR.Command.Service.Controllers
|
|
{
|
|
[Route("api/v{version:apiVersion}/order")]
|
|
[ApiVersion("1.0")]
|
|
[ApiController]
|
|
[Produces("application/json")]
|
|
[Authorize]
|
|
[SwaggerTag("API ระบบออกคำสั่ง")]
|
|
public class OrderController : BaseController
|
|
{
|
|
#region " Fields "
|
|
|
|
private readonly CommandRepository _repository;
|
|
private readonly PlacementRepository _placementRepository;
|
|
private readonly ApplicationDBContext _context;
|
|
private readonly MinIOService _documentService;
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
private readonly PrefixRepository _prefixRepository;
|
|
private readonly CommandTypeRepository _commandTypeRepository;
|
|
private readonly CommandStatusRepository _commandStatusRepository;
|
|
private readonly UserProfileRepository _userProfileRepository;
|
|
private readonly EmailSenderService _emailSenderService;
|
|
private readonly IWebHostEnvironment _hostingEnvironment;
|
|
private readonly MinIOService _minIOService;
|
|
private readonly IConfiguration _configuration;
|
|
|
|
// for add watermark
|
|
private BaseFont baseFont = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
|
|
|
|
#endregion
|
|
|
|
#region " Constuctor and Destructor "
|
|
|
|
public OrderController(CommandRepository repository,
|
|
PlacementRepository placementRepository,
|
|
ApplicationDBContext context,
|
|
MinIOService documentService,
|
|
IHttpContextAccessor httpContextAccessor,
|
|
PrefixRepository prefixRepository,
|
|
CommandTypeRepository commandTypeRepository,
|
|
CommandStatusRepository commandStatusRepository,
|
|
UserProfileRepository userProfileRepository,
|
|
EmailSenderService emailSenderService,
|
|
IWebHostEnvironment hostingEnvironment,
|
|
MinIOService minIOService,
|
|
IConfiguration configuration)
|
|
{
|
|
_repository = repository;
|
|
_context = context;
|
|
_documentService = documentService;
|
|
_httpContextAccessor = httpContextAccessor;
|
|
_placementRepository = placementRepository;
|
|
_prefixRepository = prefixRepository;
|
|
_commandTypeRepository = commandTypeRepository;
|
|
_commandStatusRepository = commandStatusRepository;
|
|
_userProfileRepository = userProfileRepository;
|
|
_emailSenderService = emailSenderService;
|
|
_hostingEnvironment = hostingEnvironment;
|
|
_minIOService = minIOService;
|
|
_configuration = configuration;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " Properties "
|
|
|
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
|
|
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
|
|
|
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
|
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
|
|
|
|
private Guid OcId
|
|
{
|
|
get
|
|
{
|
|
if (UserId != null || UserId != "")
|
|
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), token);
|
|
else
|
|
return Guid.Empty;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " Methods "
|
|
|
|
[HttpGet("mail")]
|
|
[AllowAnonymous]
|
|
public async Task<ActionResult<ResponseObject>> SendMail()
|
|
{
|
|
try
|
|
{
|
|
_repository.SendMail();
|
|
|
|
return Success();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return Error(ex);
|
|
}
|
|
}
|
|
|
|
#region " Add Watermark "
|
|
|
|
private void AddWaterMarkText(PdfContentByte pdfData, string watermarkText, BaseFont font, float fontSize, float angle, BaseColor color, Rectangle realPageSize)
|
|
{
|
|
var gstate = new PdfGState { FillOpacity = 0.5f, StrokeOpacity = 0.3f };
|
|
pdfData.SaveState();
|
|
pdfData.SetGState(gstate);
|
|
pdfData.SetColorFill(color);
|
|
pdfData.BeginText();
|
|
pdfData.SetFontAndSize(font, fontSize);
|
|
var x = (realPageSize.Right + realPageSize.Left) / 2;
|
|
var y = (realPageSize.Bottom + realPageSize.Top) / 2;
|
|
pdfData.ShowTextAligned(Element.ALIGN_CENTER, watermarkText, x, y, angle);
|
|
pdfData.EndText();
|
|
pdfData.RestoreState();
|
|
}
|
|
|
|
private bool AddWatermark(string inputfilepath, string outputfilepath, string watermark_text)
|
|
{
|
|
PdfReader pdfReader = null;
|
|
PdfStamper pdfStamper = null;
|
|
try
|
|
{
|
|
|
|
pdfReader = new PdfReader(inputfilepath);
|
|
int numberOfPages = pdfReader.NumberOfPages;
|
|
iTextSharp.text.Rectangle pagesize = pdfReader.GetPageSize(1);
|
|
pdfStamper = new PdfStamper(pdfReader, new FileStream(outputfilepath, FileMode.Create));
|
|
|
|
for (int i = 1; i <= numberOfPages; i++)
|
|
{
|
|
var dc = pdfStamper.GetOverContent(i);
|
|
AddWaterMarkText(dc, watermark_text, baseFont, 30, 45, BaseColor.DARK_GRAY, pdfReader.GetPageSizeWithRotation(i));
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ex.Message.Trim();
|
|
return false;
|
|
}
|
|
finally
|
|
{
|
|
if (pdfStamper != null)
|
|
pdfStamper.Close();
|
|
|
|
if (pdfReader != null)
|
|
pdfReader.Close();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// แสดงปีเป็นปีพุทธศักราช โดยดึงจากข้อมูลที่มีในระบบ
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// ถ้าไม่มีข้อมูลเลยจะ default ปีปัจจุบันให้ 1 รายการ
|
|
/// </remarks>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("fiscal-year")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> GetFiscalAsync()
|
|
{
|
|
var data = await _repository.GetAllAsync();
|
|
if (data != null)
|
|
{
|
|
var _data = data.GroupBy(x => x.CommandYear).Select(x => new
|
|
{
|
|
Id = x.FirstOrDefault().CommandYear.ToInteger().ToCeYear(),
|
|
Name = x.FirstOrDefault().CommandYear.ToInteger().ToThaiYear(),
|
|
}).ToList();
|
|
|
|
if (_data == null || _data.Count == 0)
|
|
{
|
|
_data!.Add(new
|
|
{
|
|
Id = DateTime.Now.Year,
|
|
Name = DateTime.Now.Year.ToThaiYear()
|
|
});
|
|
}
|
|
|
|
return Success(_data);
|
|
}
|
|
|
|
return Success(data);
|
|
}
|
|
|
|
/// <summary>
|
|
/// แสดงประเภทคำสั่ง โดยดึงจากข้อมูลที่มีในระบบ
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("order-type")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> GetCommandTypeAsync()
|
|
{
|
|
try
|
|
{
|
|
var data = (await _commandTypeRepository.GetAllAsync()).OrderBy(x => x.CommandCode);
|
|
|
|
return Success(data);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ตรวจสอบความพร้อมในการออกคำสั่ง
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns>
|
|
/// ค่า Y = พร้อมออกคำสั่ง, N = ยังไม่พร้อม
|
|
/// </returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("ready/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> CheckReadyToExcecuteAsync(Guid orderId)
|
|
{
|
|
try
|
|
{
|
|
var command = await _repository.GetByIdAsync(orderId);
|
|
if (command == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
var cover = command.Documents.FirstOrDefault(x => x.Category == GlobalConstants.TYPE_COVER);
|
|
var attatchment = command.Documents.FirstOrDefault(x => x.Category == GlobalConstants.TYPE_ATTACHMENT);
|
|
|
|
switch (command.CommandType.CommandCode.ToUpper())
|
|
{
|
|
case "C-PM-10":
|
|
case "C-PM-11":
|
|
case "C-PM-12":
|
|
case "C-PM-16":
|
|
//case "C-PM-17":
|
|
case "C-PM-18":
|
|
case "C-PM-19":
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
case "C-PM-20":
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
case "C-PM-21":
|
|
case "C-PM-22":
|
|
case "C-PM-23":
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
case "C-PM-24":
|
|
case "C-PM-25":
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
case "C-PM-26":
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
case "C-PM-27":
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
case "C-PM-28":
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
case "C-PM-29":
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
case "C-PM-30":
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
case "C-PM-31":
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
case "C-PM-32":
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
case "C-PM-33":
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
case "C-PM-34":
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
case "C-PM-35":
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
case "C-PM-36":
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
case "C-PM-37":
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
case "C-PM-38":
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
default:
|
|
{
|
|
if (command.CommandNo != "" &&
|
|
command.CommandYear != null &&
|
|
command.CommandExcecuteDate != null &&
|
|
cover != null &&
|
|
attatchment != null)
|
|
{
|
|
return Success(new { result = "Y" });
|
|
}
|
|
else
|
|
return Success(new { result = "N" });
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// เปลี่ยน status ของคำสั่งไปขั้นตอนถัดไป
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns>
|
|
/// ค่า Y = พร้อมออกคำสั่ง, N = ยังไม่พร้อม
|
|
/// </returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("next/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> GoToNextState(Guid orderId)
|
|
{
|
|
try
|
|
{
|
|
await _repository.GotoNextStateAsync(orderId);
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// เปลี่ยน status ของคำสั่งไปขั้นตอนก่อนหน้า
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns>
|
|
/// ค่า Y = พร้อมออกคำสั่ง, N = ยังไม่พร้อม
|
|
/// </returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("prev/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> GoToPrevState(Guid orderId)
|
|
{
|
|
try
|
|
{
|
|
await _repository.GotoPrevStateAsync(orderId);
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-19 : หน้าจอรายการออกคำสั่ง
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> GetAllAsync()
|
|
{
|
|
try
|
|
{
|
|
var data = (await _repository.GetAllAsync())
|
|
.Select(d => new
|
|
{
|
|
OrderId = d.Id,
|
|
OrderName = d.CommandSubject,
|
|
OrderNo = d.CommandNo,
|
|
FiscalYear = d.CommandYear,
|
|
OrderDate = d.CommandAffectDate,
|
|
OrderByOrganization = d.IssuerOrganizationName,
|
|
OrderBy = d.IssuerOrganizationName,
|
|
OrderById = d.IssuerOrganizationId,
|
|
signatoryBy = d.AuthorizedUserFullName,
|
|
signatoryPosition = d.AuthorizedPosition,
|
|
OrderStatusValue = d.CommandStatusId,
|
|
OrderStatusName = d.CommandStatus.Name,
|
|
OrderTypeValue = d.CommandTypeId,
|
|
OrderTypeName = d.CommandType.Name,
|
|
FaultLevel = d.FaultLevel,
|
|
CaseFault = d.CaseFault,
|
|
Result = d.Result,
|
|
RefRaw = d.RefRaw,
|
|
FullName = d.Receivers.FirstOrDefault() == null ? null : $"{d.Receivers.FirstOrDefault().Prefix!}{d.Receivers.FirstOrDefault().FirstName!} {d.Receivers.FirstOrDefault().LastName!}",
|
|
}).ToList();
|
|
return Success(data);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-20 : ลบรายการคำสั่ง
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpDelete("{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> DeleteAsync(Guid orderId)
|
|
{
|
|
try
|
|
{
|
|
var data = await _repository.GetByIdAsync(orderId);
|
|
if (data == null)
|
|
throw new Exception(GlobalMessages.DataNotFound);
|
|
|
|
await _repository.DeleteAsync(data!);
|
|
|
|
return Success(data);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-21 : รายละเอียดการออกคำสั่ง
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> GetByIdAsync(Guid orderId)
|
|
{
|
|
try
|
|
{
|
|
var data = await _repository.GetByIdAsync(orderId);
|
|
if (data == null)
|
|
throw new Exception(GlobalMessages.DataNotFound);
|
|
|
|
var result = new
|
|
{
|
|
orderId = orderId,
|
|
orderTypeValue = data.CommandTypeId,
|
|
orderTypeCode = data.CommandType.CommandCode.ToLower(),
|
|
orderTitle = data.CommandSubject,
|
|
orderNo = data.CommandNo,
|
|
orderYear = data.CommandYear,
|
|
orderDate = data.CommandAffectDate,
|
|
orderBy = data.IssuerOrganizationId,
|
|
signatoryBy = data.AuthorizedUserFullName,
|
|
signatoryPosition = data.AuthorizedPosition,
|
|
examRound = data.Placement == null ? Guid.Empty : data.Placement.Id,
|
|
registerPosition = "",
|
|
conclusionRegisterNo = data.ConclusionRegisterNo,
|
|
conclusionRegisterDate = data.ConclusionRegisterDate,
|
|
conclusionResultNo = data.ConclusionResultNo,
|
|
conclusionResultDate = data.ConclusionResultDate,
|
|
|
|
conclusionMeetingNo = data.ConclusionMeetingNo,
|
|
conclusionMeetingDate = data.ConclusionMeetingDate,
|
|
|
|
conclusionReturnNo = data.ConclusionReturnNo,
|
|
conclusionReturnDate = data.ConclusionReturnDate,
|
|
|
|
sourceOrganizationName = data.SourceOrganizationName,
|
|
militaryCommandNo = data.MilitaryCommandNo,
|
|
militaryCommanDate = data.MilitaryCommanDate,
|
|
|
|
placementCommandIssuer = data.PlacementCommandIssuer,
|
|
placementCommandNo = data.PlacementCommandNo,
|
|
placementCommandDate = data.PlacementCommandDate,
|
|
|
|
conclusionTranferNo = data.ConclusionTranferNo,
|
|
conclusionTranferDate = data.ConclusionTranferDate,
|
|
|
|
placementPositionName = data.PlacementPositionName,
|
|
placementOrganizationName = data.PlacementOrganizationName,
|
|
probationStartDate = data.ProbationStartDate,
|
|
probationEndDate = data.ProbationEndDate,
|
|
chairManFullName = data.ChairManFullName,
|
|
member1FullName = data.Member1FullName,
|
|
member2FullName = data.Member2FullName,
|
|
|
|
receiveOrganizationName = data.ReceiveOrganizationName,
|
|
|
|
transferOrganizationName = data.TransferOrganizationName,
|
|
conclusionReceiveNo = data.ConclusionReceiveNo,
|
|
conclusionReceiveDate = data.ConclusionReceiveDate,
|
|
|
|
govAidCommandNo = data.GovAidCommandNo,
|
|
govAidCommandDate = data.GovAidCommandDate,
|
|
|
|
fault = data.Fault,
|
|
guiltyBasis = data.GuiltyBasis,
|
|
conclusionFireNo = data.ConclusionFireNo,
|
|
conclusionFireDate = data.ConclusionFireDate,
|
|
conclusionFireResolution = data.ConclusionFireResolution,
|
|
|
|
OrderStatusValue = data.CommandStatusId,
|
|
OrderStatusName = data.CommandStatus.Name,
|
|
|
|
FaultLevel = data.FaultLevel,
|
|
CaseFault = data.CaseFault,
|
|
Result = data.Result,
|
|
RefRaw = data.RefRaw,
|
|
ComplaintId = data.ComplaintId,
|
|
|
|
SalaryPeriodId = data.SalaryPeriodId,
|
|
SalaryPeriod = data.SalaryPeriod,
|
|
Year = data.Year,
|
|
};
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#region " Put and Post "
|
|
|
|
#region " C-PM-01 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-01
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-01/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType01Async([FromBody] CreateCommandRequest req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
PositionName = req.registerPosition,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
// c-pm-01 ถึง c-pm-04
|
|
PlacementId = req.examRound,
|
|
ConclusionRegisterNo = req.conclusionRegisterNo ?? "",
|
|
ConclusionRegisterDate = req.conclusionRegisterDate,
|
|
ConclusionResultNo = req.conclusionResultNo,
|
|
ConclusionResultDate = req.conclusionResultDate,
|
|
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-01
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-01/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType01Async(Guid orderId, [FromBody] CreateCommandRequest req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
order.PositionName = req.registerPosition;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
// c-pm-01 ถึง c-pm-04
|
|
|
|
// var placement = await _placementRepository.GetByIdAsync(req.examRound);
|
|
// order.Placement = placement!;
|
|
order.ConclusionRegisterNo = req.conclusionRegisterNo;
|
|
order.ConclusionRegisterDate = req.conclusionRegisterDate;
|
|
order.ConclusionResultNo = req.conclusionResultNo;
|
|
order.ConclusionResultDate = req.conclusionResultDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-02 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-02
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-02/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType02Async([FromBody] CreateCommandRequest req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
PositionName = req.registerPosition,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
// c-pm-01 ถึง c-pm-04
|
|
PlacementId = req.examRound,
|
|
ConclusionRegisterNo = req.conclusionRegisterNo ?? "",
|
|
ConclusionRegisterDate = req.conclusionRegisterDate,
|
|
ConclusionResultNo = req.conclusionResultNo,
|
|
ConclusionResultDate = req.conclusionResultDate,
|
|
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-02
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-02/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType02Async(Guid orderId, [FromBody] CreateCommandRequest req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
order.PositionName = req.registerPosition;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
// c-pm-01 ถึง c-pm-04
|
|
|
|
// var placement = await _placementRepository.GetByIdAsync(req.examRound);
|
|
// order.Placement = placement!;
|
|
order.ConclusionRegisterNo = req.conclusionRegisterNo;
|
|
order.ConclusionRegisterDate = req.conclusionRegisterDate;
|
|
order.ConclusionResultNo = req.conclusionResultNo;
|
|
order.ConclusionResultDate = req.conclusionResultDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-03 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-03
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-03/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType03Async([FromBody] CreateCommandRequest req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
PositionName = req.registerPosition,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
// c-pm-01 ถึง c-pm-04
|
|
PlacementId = req.examRound,
|
|
ConclusionRegisterNo = req.conclusionRegisterNo ?? "",
|
|
ConclusionRegisterDate = req.conclusionRegisterDate,
|
|
ConclusionResultNo = req.conclusionResultNo,
|
|
ConclusionResultDate = req.conclusionResultDate,
|
|
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-04
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-03/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType03Async(Guid orderId, [FromBody] CreateCommandRequest req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
order.PositionName = req.registerPosition;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
// c-pm-01 ถึง c-pm-04
|
|
|
|
// var placement = await _placementRepository.GetByIdAsync(req.examRound);
|
|
// order.Placement = placement!;
|
|
order.ConclusionRegisterNo = req.conclusionRegisterNo;
|
|
order.ConclusionRegisterDate = req.conclusionRegisterDate;
|
|
order.ConclusionResultNo = req.conclusionResultNo;
|
|
order.ConclusionResultDate = req.conclusionResultDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-04 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-04
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-04/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType04Async([FromBody] CreateCommandRequest req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
PositionName = req.registerPosition,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
// c-pm-01 ถึง c-pm-04
|
|
PlacementId = req.examRound,
|
|
ConclusionRegisterNo = req.conclusionRegisterNo ?? "",
|
|
ConclusionRegisterDate = req.conclusionRegisterDate,
|
|
ConclusionResultNo = req.conclusionResultNo,
|
|
ConclusionResultDate = req.conclusionResultDate,
|
|
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-04
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-04/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType04Async(Guid orderId, [FromBody] CreateCommandRequest req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
order.PositionName = req.registerPosition;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
// c-pm-01 ถึง c-pm-04
|
|
|
|
// var placement = await _placementRepository.GetByIdAsync(req.examRound);
|
|
// order.Placement = placement!;
|
|
order.ConclusionRegisterNo = req.conclusionRegisterNo;
|
|
order.ConclusionRegisterDate = req.conclusionRegisterDate;
|
|
order.ConclusionResultNo = req.conclusionResultNo;
|
|
order.ConclusionResultDate = req.conclusionResultDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-39 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-39
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-39/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType39Async([FromBody] CreateCommandRequest req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
PositionName = req.registerPosition,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
// c-pm-01 ถึง c-pm-04
|
|
PlacementId = req.examRound,
|
|
ConclusionRegisterNo = req.conclusionRegisterNo ?? "",
|
|
ConclusionRegisterDate = req.conclusionRegisterDate,
|
|
ConclusionResultNo = req.conclusionResultNo,
|
|
ConclusionResultDate = req.conclusionResultDate,
|
|
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-39
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-39/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType39Async(Guid orderId, [FromBody] CreateCommandRequest req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
order.PositionName = req.registerPosition;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
// c-pm-01 ถึง c-pm-04
|
|
|
|
// var placement = await _placementRepository.GetByIdAsync(req.examRound);
|
|
// order.Placement = placement!;
|
|
order.ConclusionRegisterNo = req.conclusionRegisterNo;
|
|
order.ConclusionRegisterDate = req.conclusionRegisterDate;
|
|
order.ConclusionResultNo = req.conclusionResultNo;
|
|
order.ConclusionResultDate = req.conclusionResultDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-05 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-05
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-05/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType05Async([FromBody] CreateCommandGroup2Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
ConclusionMeetingNo = req.conclusionMeetingNo,
|
|
ConclusionMeetingDate = req.conclusionMeetingDate,
|
|
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-05
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-05/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType05Async(Guid orderId, [FromBody] CreateCommandGroup2Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
order.ConclusionMeetingNo = req.conclusionMeetingNo;
|
|
order.ConclusionMeetingDate = req.conclusionMeetingDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-06 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-06
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-06/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType06Async([FromBody] CreateCommandGroup2Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
ConclusionMeetingNo = req.conclusionMeetingNo,
|
|
ConclusionMeetingDate = req.conclusionMeetingDate,
|
|
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-06
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-06/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType06Async(Guid orderId, [FromBody] CreateCommandGroup2Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
order.ConclusionMeetingNo = req.conclusionMeetingNo;
|
|
order.ConclusionMeetingDate = req.conclusionMeetingDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-07 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-07
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-07/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType07Async([FromBody] CreateCommandGroup3Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-07
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-07/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType07Async(Guid orderId, [FromBody] CreateCommandGroup3Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-08 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-08
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-08/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType08Async([FromBody] CreateCommandGroup4Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
ConclusionReturnNo = req.conclusionReturnNo,
|
|
ConclusionReturnDate = req.conclusionReturnDate,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-08
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-08/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType08Async(Guid orderId, [FromBody] CreateCommandGroup4Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
|
|
order.ConclusionReturnNo = req.conclusionReturnNo;
|
|
order.ConclusionReturnDate = req.conclusionReturnDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-09 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-09
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-09/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType09Async([FromBody] CreateCommandGroup5Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
ConclusionReturnNo = req.conclusionReturnNo,
|
|
ConclusionReturnDate = req.conclusionReturnDate,
|
|
SourceOrganizationName = req.sourceOrganizationName,
|
|
MilitaryCommandNo = req.militaryCommandNo,
|
|
MilitaryCommanDate = req.militaryCommandDate
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-09
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-09/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType09Async(Guid orderId, [FromBody] CreateCommandGroup5Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
|
|
order.ConclusionReturnNo = req.conclusionReturnNo;
|
|
order.ConclusionReturnDate = req.conclusionReturnDate;
|
|
order.SourceOrganizationName = req.sourceOrganizationName;
|
|
order.MilitaryCommandNo = req.militaryCommandNo;
|
|
order.MilitaryCommanDate = req.militaryCommandDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-10 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-10
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-10/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType10Async([FromBody] CreateCommandGroup6Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
PlacementCommandIssuer = req.placementCommandIssuer,
|
|
PlacementCommandNo = req.placementCommandNo,
|
|
PlacementCommandDate = req.placementCommandDate,
|
|
PlacementPositionName = req.placementPositionName,
|
|
PlacementOrganizationName = req.placementOrganizationName,
|
|
ProbationStartDate = req.probationStartDate,
|
|
ProbationEndDate = req.probationEndDate,
|
|
ChairManFullName = req.chairManFullName,
|
|
Member1FullName = req.member1FullName,
|
|
Member2FullName = req.member2FullName,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-10
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-10/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType10Async(Guid orderId, [FromBody] CreateCommandGroup6Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
order.PlacementCommandIssuer = req.placementCommandIssuer;
|
|
order.PlacementCommandNo = req.placementCommandNo;
|
|
order.PlacementCommandDate = req.placementCommandDate;
|
|
order.PlacementPositionName = req.placementPositionName;
|
|
order.PlacementOrganizationName = req.placementOrganizationName;
|
|
order.ProbationStartDate = req.probationStartDate;
|
|
order.ProbationEndDate = req.probationEndDate;
|
|
order.ChairManFullName = req.chairManFullName;
|
|
order.Member1FullName = req.member1FullName;
|
|
order.Member2FullName = req.member2FullName;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-11 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-11
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-11/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType11Async([FromBody] CreateCommandGroup7Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
PlacementCommandIssuer = req.placementCommandIssuer,
|
|
PlacementCommandNo = req.placementCommandNo,
|
|
PlacementCommandDate = req.placementCommandDate,
|
|
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-11
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-11/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType11Async(Guid orderId, [FromBody] CreateCommandGroup7Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
order.PlacementCommandIssuer = req.placementCommandIssuer;
|
|
order.PlacementCommandNo = req.placementCommandNo;
|
|
order.PlacementCommandDate = req.placementCommandDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-12 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-12
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-12/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType12Async([FromBody] CreateCommandGroup7Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
PlacementCommandIssuer = req.placementCommandIssuer,
|
|
PlacementCommandNo = req.placementCommandNo,
|
|
PlacementCommandDate = req.placementCommandDate,
|
|
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-12
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-12/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType12Async(Guid orderId, [FromBody] CreateCommandGroup7Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
order.PlacementCommandIssuer = req.placementCommandIssuer;
|
|
order.PlacementCommandNo = req.placementCommandNo;
|
|
order.PlacementCommandDate = req.placementCommandDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-13 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-13
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-13/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType13Async([FromBody] CreateCommandGroup8Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
ReceiveOrganizationName = req.receiveOrganizationName,
|
|
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-13
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-13/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType13Async(Guid orderId, [FromBody] CreateCommandGroup8Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
order.ReceiveOrganizationName = req.receiveOrganizationName;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-14 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-14
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-14/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType14Async([FromBody] CreateCommandGroup9Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
TransferOrganizationName = req.transferOrganizationName,
|
|
ConclusionReceiveNo = req.conclusionReceiveNo,
|
|
ConclusionReceiveDate = req.conclusionReceiveDate,
|
|
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-14
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-14/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType14Async(Guid orderId, [FromBody] CreateCommandGroup9Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
order.TransferOrganizationName = req.transferOrganizationName;
|
|
order.ConclusionReceiveNo = req.conclusionReceiveNo;
|
|
order.ConclusionReceiveDate = req.conclusionReceiveDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-15 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-15
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-15/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType15Async([FromBody] CreateCommandGroup0Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-15
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-15/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType15Async(Guid orderId, [FromBody] CreateCommandGroup0Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-16 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-16
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-16/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType16Async([FromBody] CreateCommandGroup10Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
GovAidCommandNo = req.govAidCommandNo,
|
|
GovAidCommandDate = req.govAidCommandDate,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-16
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-16/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType16Async(Guid orderId, [FromBody] CreateCommandGroup10Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
order.GovAidCommandNo = req.govAidCommandNo;
|
|
order.GovAidCommandDate = req.govAidCommandDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-17 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-17
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-17/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType17Async([FromBody] CreateCommandGroup0Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-17
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-17/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType17Async(Guid orderId, [FromBody] CreateCommandGroup0Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-18 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-18
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-18/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType18Async([FromBody] CreateCommandGroup14Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
Fault = req.fault,
|
|
GuiltyBasis = req.guiltyBasis,
|
|
ConclusionFireNo = req.conclusionFireNo,
|
|
ConclusionFireDate = req.conclusionFireDate,
|
|
ConclusionFireResolution = req.conclusionFireResolution,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-18
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-18/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType18Async(Guid orderId, [FromBody] CreateCommandGroup14Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
order.Fault = req.fault;
|
|
order.GuiltyBasis = req.guiltyBasis;
|
|
order.ConclusionFireNo = req.conclusionFireNo;
|
|
order.ConclusionFireDate = req.conclusionFireDate;
|
|
order.ConclusionFireResolution = req.conclusionFireResolution;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-19 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-19
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-19/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType19Async([FromBody] CreateCommandGroup11Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
Fault = req.fault,
|
|
GuiltyBasis = req.guiltyBasis,
|
|
ConclusionFireNo = req.conclusionFireNo,
|
|
ConclusionFireDate = req.conclusionFireDate,
|
|
ConclusionFireResolution = req.conclusionFireResolution,
|
|
|
|
CaseFault = req.caseFault,
|
|
FaultLevel = req.faultLevel,
|
|
RefRaw = req.refRaw,
|
|
Result = req.result,
|
|
ComplaintId = req.complaintId,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-19
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-19/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType19Async(Guid orderId, [FromBody] CreateCommandGroup11Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
order.Fault = req.fault;
|
|
order.GuiltyBasis = req.guiltyBasis;
|
|
order.ConclusionFireNo = req.conclusionFireNo;
|
|
order.ConclusionFireDate = req.conclusionFireDate;
|
|
order.ConclusionFireResolution = req.conclusionFireResolution;
|
|
|
|
order.CaseFault = req.caseFault;
|
|
order.FaultLevel = req.faultLevel;
|
|
order.RefRaw = req.refRaw;
|
|
order.Result = req.result;
|
|
order.ComplaintId = req.complaintId;
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-20 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-20
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-20/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType20Async([FromBody] CreateCommandGroup11Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
Fault = req.fault,
|
|
GuiltyBasis = req.guiltyBasis,
|
|
ConclusionFireNo = req.conclusionFireNo,
|
|
ConclusionFireDate = req.conclusionFireDate,
|
|
ConclusionFireResolution = req.conclusionFireResolution,
|
|
|
|
CaseFault = req.caseFault,
|
|
FaultLevel = req.faultLevel,
|
|
RefRaw = req.refRaw,
|
|
Result = req.result,
|
|
ComplaintId = req.complaintId,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-20
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-20/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType20Async(Guid orderId, [FromBody] CreateCommandGroup11Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
order.Fault = req.fault;
|
|
order.GuiltyBasis = req.guiltyBasis;
|
|
order.ConclusionFireNo = req.conclusionFireNo;
|
|
order.ConclusionFireDate = req.conclusionFireDate;
|
|
order.ConclusionFireResolution = req.conclusionFireResolution;
|
|
|
|
order.CaseFault = req.caseFault;
|
|
order.FaultLevel = req.faultLevel;
|
|
order.RefRaw = req.refRaw;
|
|
order.Result = req.result;
|
|
order.ComplaintId = req.complaintId;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-21 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-21
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-21/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType21Async([FromBody] CreateCommandGroup7Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
PlacementCommandIssuer = req.placementCommandIssuer,
|
|
PlacementCommandNo = req.placementCommandNo,
|
|
PlacementCommandDate = req.placementCommandDate,
|
|
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-21
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-21/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType21Async(Guid orderId, [FromBody] CreateCommandGroup7Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
//order.PlacementCommandIssuer = req.placementCommandIssuer;
|
|
//order.PlacementCommandNo = req.placementCommandNo;
|
|
//order.PlacementCommandDate = req.placementCommandDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-22 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-22
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-22/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType22Async([FromBody] CreateCommandGroup0Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-22
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-22/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType22Async(Guid orderId, [FromBody] CreateCommandGroup0Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-23 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-23
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-23/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType23Async([FromBody] CreateCommandGroup0Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-23
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-23/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType23Async(Guid orderId, [FromBody] CreateCommandGroup0Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-24 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-24
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-24/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType24Async([FromBody] CreateCommandGroup12Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
ConclusionTranferNo = req.conclusionTranferNo,
|
|
ConclusionTranferDate = req.conclusionTranferDate,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-24
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-24/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType24Async(Guid orderId, [FromBody] CreateCommandGroup12Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
order.ConclusionTranferNo = req.conclusionTranferNo;
|
|
order.ConclusionTranferDate = req.conclusionTranferDate;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-25 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-25
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-25/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType25Async([FromBody] CreateCommandGroup13Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
CaseFault = req.caseFault,
|
|
FaultLevel = req.faultLevel,
|
|
RefRaw = req.refRaw,
|
|
Result = req.result,
|
|
ComplaintId = req.complaintId,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-25
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-25/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType25Async(Guid orderId, [FromBody] CreateCommandGroup13Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
order.CaseFault = req.caseFault;
|
|
order.FaultLevel = req.faultLevel;
|
|
order.RefRaw = req.refRaw;
|
|
order.Result = req.result;
|
|
order.ComplaintId = req.complaintId;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-26 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-26
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-26/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType26Async([FromBody] CreateCommandGroup13Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
CaseFault = req.caseFault,
|
|
FaultLevel = req.faultLevel,
|
|
RefRaw = req.refRaw,
|
|
Result = req.result,
|
|
ComplaintId = req.complaintId,
|
|
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-26
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-26/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType26Async(Guid orderId, [FromBody] CreateCommandGroup13Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
order.CaseFault = req.caseFault;
|
|
order.FaultLevel = req.faultLevel;
|
|
order.RefRaw = req.refRaw;
|
|
order.Result = req.result;
|
|
order.ComplaintId = req.complaintId;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-27 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-27
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-27/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType27Async([FromBody] CreateCommandGroup13Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
CaseFault = req.caseFault,
|
|
FaultLevel = req.faultLevel,
|
|
RefRaw = req.refRaw,
|
|
Result = req.result,
|
|
ComplaintId = req.complaintId,
|
|
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-27
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-27/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType27Async(Guid orderId, [FromBody] CreateCommandGroup13Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
order.CaseFault = req.caseFault;
|
|
order.FaultLevel = req.faultLevel;
|
|
order.RefRaw = req.refRaw;
|
|
order.Result = req.result;
|
|
order.ComplaintId = req.complaintId;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-28 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-28
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-28/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType28Async([FromBody] CreateCommandGroup13Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
CaseFault = req.caseFault,
|
|
FaultLevel = req.faultLevel,
|
|
RefRaw = req.refRaw,
|
|
Result = req.result,
|
|
ComplaintId = req.complaintId,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-28
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-28/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType28Async(Guid orderId, [FromBody] CreateCommandGroup13Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
order.CaseFault = req.caseFault;
|
|
order.FaultLevel = req.faultLevel;
|
|
order.RefRaw = req.refRaw;
|
|
order.Result = req.result;
|
|
order.ComplaintId = req.complaintId;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-29 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-29
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-29/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType29Async([FromBody] CreateCommandGroup13Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
CaseFault = req.caseFault,
|
|
FaultLevel = req.faultLevel,
|
|
RefRaw = req.refRaw,
|
|
Result = req.result,
|
|
ComplaintId = req.complaintId,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-29
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-29/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType29Async(Guid orderId, [FromBody] CreateCommandGroup13Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
order.CaseFault = req.caseFault;
|
|
order.FaultLevel = req.faultLevel;
|
|
order.RefRaw = req.refRaw;
|
|
order.Result = req.result;
|
|
order.ComplaintId = req.complaintId;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-30 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-30
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-30/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType30Async([FromBody] CreateCommandGroup13Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
CaseFault = req.caseFault,
|
|
FaultLevel = req.faultLevel,
|
|
RefRaw = req.refRaw,
|
|
Result = req.result,
|
|
ComplaintId = req.complaintId,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-30
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-30/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType30Async(Guid orderId, [FromBody] CreateCommandGroup13Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
order.CaseFault = req.caseFault;
|
|
order.FaultLevel = req.faultLevel;
|
|
order.RefRaw = req.refRaw;
|
|
order.Result = req.result;
|
|
order.ComplaintId = req.complaintId;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-31 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-31
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-31/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType31Async([FromBody] CreateCommandGroup13Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
CaseFault = req.caseFault,
|
|
FaultLevel = req.faultLevel,
|
|
RefRaw = req.refRaw,
|
|
Result = req.result,
|
|
ComplaintId = req.complaintId,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-31
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-31/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType31Async(Guid orderId, [FromBody] CreateCommandGroup13Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
order.CaseFault = req.caseFault;
|
|
order.FaultLevel = req.faultLevel;
|
|
order.RefRaw = req.refRaw;
|
|
order.Result = req.result;
|
|
order.ComplaintId = req.complaintId;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-32 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-32
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-32/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType32Async([FromBody] CreateCommandGroup13Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
CaseFault = req.caseFault,
|
|
FaultLevel = req.faultLevel,
|
|
RefRaw = req.refRaw,
|
|
Result = req.result,
|
|
ComplaintId = req.complaintId,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-32
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-32/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType32Async(Guid orderId, [FromBody] CreateCommandGroup13Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
order.CaseFault = req.caseFault;
|
|
order.FaultLevel = req.faultLevel;
|
|
order.RefRaw = req.refRaw;
|
|
order.Result = req.result;
|
|
order.ComplaintId = req.complaintId;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-33 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-33
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-33/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType33Async([FromBody] CreateCommandGroup15Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
CaseFault = req.caseFault,
|
|
FaultLevel = req.faultLevel,
|
|
RefRaw = req.refRaw,
|
|
Result = req.result,
|
|
SalaryPeriodId = req.salaryPeriodId,
|
|
SalaryPeriod = req.salaryPeriod,
|
|
Year = req.year,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-33
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-33/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType33Async(Guid orderId, [FromBody] CreateCommandGroup15Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
order.CaseFault = req.caseFault;
|
|
order.FaultLevel = req.faultLevel;
|
|
order.RefRaw = req.refRaw;
|
|
order.Result = req.result;
|
|
order.SalaryPeriodId = req.salaryPeriodId;
|
|
order.SalaryPeriod = req.salaryPeriod;
|
|
order.Year = req.year;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-34 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-34
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-34/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType34Async([FromBody] CreateCommandGroup15Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
CaseFault = req.caseFault,
|
|
FaultLevel = req.faultLevel,
|
|
RefRaw = req.refRaw,
|
|
Result = req.result,
|
|
SalaryPeriodId = req.salaryPeriodId,
|
|
SalaryPeriod = req.salaryPeriod,
|
|
Year = req.year,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-34
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-34/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType34Async(Guid orderId, [FromBody] CreateCommandGroup15Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
order.CaseFault = req.caseFault;
|
|
order.FaultLevel = req.faultLevel;
|
|
order.RefRaw = req.refRaw;
|
|
order.Result = req.result;
|
|
order.SalaryPeriodId = req.salaryPeriodId;
|
|
order.SalaryPeriod = req.salaryPeriod;
|
|
order.Year = req.year;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-35 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-35
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-35/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType35Async([FromBody] CreateCommandGroup15Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
CaseFault = req.caseFault,
|
|
FaultLevel = req.faultLevel,
|
|
RefRaw = req.refRaw,
|
|
Result = req.result,
|
|
SalaryPeriodId = req.salaryPeriodId,
|
|
SalaryPeriod = req.salaryPeriod,
|
|
Year = req.year,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-35
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-35/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType35Async(Guid orderId, [FromBody] CreateCommandGroup15Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
order.CaseFault = req.caseFault;
|
|
order.FaultLevel = req.faultLevel;
|
|
order.RefRaw = req.refRaw;
|
|
order.Result = req.result;
|
|
order.SalaryPeriodId = req.salaryPeriodId;
|
|
order.SalaryPeriod = req.salaryPeriod;
|
|
order.Year = req.year;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-36 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-36
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-36/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType36Async([FromBody] CreateCommandGroup15Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
CaseFault = req.caseFault,
|
|
FaultLevel = req.faultLevel,
|
|
RefRaw = req.refRaw,
|
|
Result = req.result,
|
|
SalaryPeriodId = req.salaryPeriodId,
|
|
SalaryPeriod = req.salaryPeriod,
|
|
Year = req.year,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-36
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-36/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType36Async(Guid orderId, [FromBody] CreateCommandGroup15Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
order.CaseFault = req.caseFault;
|
|
order.FaultLevel = req.faultLevel;
|
|
order.RefRaw = req.refRaw;
|
|
order.Result = req.result;
|
|
order.SalaryPeriodId = req.salaryPeriodId;
|
|
order.SalaryPeriod = req.salaryPeriod;
|
|
order.Year = req.year;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-37 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-37
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-37/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType37Async([FromBody] CreateCommandGroup15Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
CaseFault = req.caseFault,
|
|
FaultLevel = req.faultLevel,
|
|
RefRaw = req.refRaw,
|
|
Result = req.result,
|
|
SalaryPeriodId = req.salaryPeriodId,
|
|
SalaryPeriod = req.salaryPeriod,
|
|
Year = req.year,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-37
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-37/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType37Async(Guid orderId, [FromBody] CreateCommandGroup15Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
order.CaseFault = req.caseFault;
|
|
order.FaultLevel = req.faultLevel;
|
|
order.RefRaw = req.refRaw;
|
|
order.Result = req.result;
|
|
order.SalaryPeriodId = req.salaryPeriodId;
|
|
order.SalaryPeriod = req.salaryPeriod;
|
|
order.Year = req.year;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " C-PM-38 "
|
|
|
|
/// <summary>
|
|
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-38
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("c-pm-38/detail")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostType38Async([FromBody] CreateCommandGroup15Request req)
|
|
{
|
|
try
|
|
{
|
|
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
|
|
var inserted = new Domain.Models.Commands.Core.Command
|
|
{
|
|
CommandNo = req.orderNo,
|
|
CommandYear = req.orderYear.ToString(),
|
|
CommandSubject = req.orderTitle,
|
|
CommandTypeId = req.orderTypeValue,
|
|
IssuerOrganizationId = req.orderBy,
|
|
IssuerOrganizationName = req.orderByOrganizationName,
|
|
AuthorizedUserFullName = req.signatoryBy,
|
|
AuthorizedPosition = req.signatoryPosition,
|
|
CommandAffectDate = req.orderDate,
|
|
OwnerGovId = OcId,
|
|
|
|
CaseFault = req.caseFault,
|
|
FaultLevel = req.faultLevel,
|
|
RefRaw = req.refRaw,
|
|
Result = req.result,
|
|
SalaryPeriodId = req.salaryPeriodId,
|
|
SalaryPeriod = req.salaryPeriod,
|
|
Year = req.year,
|
|
};
|
|
|
|
var result = await _repository.AddAsync(inserted);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-38
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("c-pm-38/detail/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PutType38Async(Guid orderId, [FromBody] CreateCommandGroup15Request req)
|
|
{
|
|
try
|
|
{
|
|
var order = await _repository.GetByIdAsync(orderId);
|
|
if (order == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
|
|
// var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
|
|
// var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
|
|
|
|
order.CommandNo = req.orderNo;
|
|
order.CommandYear = req.orderYear.ToString();
|
|
order.CommandSubject = req.orderTitle;
|
|
// order.CommandType = commandType!;
|
|
order.IssuerOrganizationId = req.orderBy;
|
|
order.IssuerOrganizationName = req.orderByOrganizationName;
|
|
order.AuthorizedUserFullName = req.signatoryBy;
|
|
order.AuthorizedPosition = req.signatoryPosition;
|
|
// order.CommandStatus = status!;
|
|
order.CommandAffectDate = req.orderDate;
|
|
order.CaseFault = req.caseFault;
|
|
order.FaultLevel = req.faultLevel;
|
|
order.RefRaw = req.refRaw;
|
|
order.Result = req.result;
|
|
order.SalaryPeriodId = req.salaryPeriodId;
|
|
order.SalaryPeriod = req.salaryPeriod;
|
|
order.Year = req.year;
|
|
|
|
var result = await _repository.UpdateAsync(order);
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// PM7-24 : dropdown รอบการสอบ หน้ารายละเอียดการออกคำสั่ง
|
|
/// </summary>
|
|
/// <param name="commandCode">Code ของประเภทคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("detail/exam-round/{commandCode}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> GetExamRoundAsync(string commandCode)
|
|
{
|
|
try
|
|
{
|
|
var rawData = commandCode.Trim().ToUpper() == "C-PM-01" ? await _placementRepository.GetCompetitivePlacementAsync() :
|
|
commandCode.Trim().ToUpper() == "C-PM-02" ? await _placementRepository.GetQualifyingPlacementAsync() :
|
|
await _placementRepository.GetAllPlacementAsync();
|
|
|
|
|
|
var data = rawData.Select(x => new
|
|
{
|
|
examRoundValue = x.Id,
|
|
examRoundName = $"{x.Name} ครั้งที่ {x.Round}/{x.Year.ToThaiYear()}"
|
|
|
|
})
|
|
.ToList();
|
|
|
|
return Success(data);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-26 : ข้อมูลเลือกรายชื่อออกคำสั่ง ** ยังไม่ได้กรองหน่วยงาน ** ** แสดงรายการจากระบบบรรจุ **
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("persons/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> GetCommandReceiverAsync([FromHeader] string authorization, Guid orderId)
|
|
{
|
|
try
|
|
{
|
|
var token = string.Empty;
|
|
if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue))
|
|
{
|
|
// we have a valid AuthenticationHeaderValue that has the following details:
|
|
|
|
var scheme = headerValue.Scheme;
|
|
token = headerValue.Parameter;
|
|
|
|
// scheme will be "Bearer"
|
|
// parmameter will be the token itself.
|
|
}
|
|
|
|
|
|
var command = await _repository.GetByIdAsync(orderId);
|
|
if (command == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
// TODO : หาค่า Education มาแสดง
|
|
var existed = await _repository.GetReceiverByCommmandIdAsync(orderId);
|
|
|
|
var receivers = (await _repository.GetReceiverForCommandAsync(orderId, token!))
|
|
.OrderBy(x => x.Sequence)
|
|
.Select(r => new CommandReceiverResponse
|
|
{
|
|
RefRecordId = r.RefPlacementProfileId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : r.RefPlacementProfileId.Value,
|
|
PersonalId = r.Id,
|
|
Sequence = r.Sequence,
|
|
IdCard = r.CitizenId,
|
|
Name = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
SelectStatus = r.RefPlacementProfileId == null ? false : (existed.FirstOrDefault(x => x.RefPlacementProfileId!.Value == r.RefPlacementProfileId!.Value) != null),
|
|
Education = "", // ยังหาไม่เจอว่าอยุ่ field ไหน
|
|
Organization = r.Organization == null ? null : r.Organization,
|
|
PositionName = r.PositionName == null ? null : r.PositionName,
|
|
PositionLevel = r.PositionLevel == null ? null : r.PositionLevel,
|
|
PositionType = r.PositionType == null ? null : r.PositionType,
|
|
PositionNumber = r.PositionNumber == null ? null : r.PositionNumber,
|
|
BirthDate = r.BirthDate == null ? null : r.BirthDate,
|
|
}).ToList();
|
|
|
|
// ให้ Update Salary เฉพาะของ Command 01-04
|
|
switch (command.CommandType.CommandCode.ToUpper())
|
|
{
|
|
case "C-PM-01":
|
|
case "C-PM-02":
|
|
case "C-PM-03":
|
|
case "c-PM-04":
|
|
{
|
|
foreach (var r in receivers)
|
|
{
|
|
var salary = await _repository.GetPlacementSalaryAsync(r.RefRecordId);
|
|
r.SalaryAmount = salary.SalaryAmount;
|
|
r.PositionSalaryAmount = salary.PositionSalaryAmount;
|
|
r.MonthSalaryAmount = salary.MonthSalaryAmount;
|
|
}
|
|
}
|
|
break;
|
|
case "c-PM-39":
|
|
{
|
|
foreach (var r in receivers)
|
|
{
|
|
var salary = await _repository.GetPlacementSalaryAsync(r.RefRecordId);
|
|
r.SalaryAmount = salary.SalaryAmount;
|
|
r.PositionSalaryAmount = salary.PositionSalaryAmount;
|
|
r.MonthSalaryAmount = salary.MonthSalaryAmount;
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
{
|
|
foreach (var r in receivers)
|
|
{
|
|
var salary = await _repository.GetCommandReceiverSalary(r.PersonalId, r.SalaryAmount, r.MonthSalaryAmount, r.PositionSalaryAmount);
|
|
r.SalaryAmount = salary.SalaryAmount;
|
|
r.PositionSalaryAmount = salary.PositionSalaryAmount;
|
|
r.MonthSalaryAmount = salary.MonthSalaryAmount;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
return Success(receivers);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// ข้อมูลเลือกรายชื่อออกคำสั่ง ** ที่ได้เลือกเอาไว้แล้ว **
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("persons-selected/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> GetCommandSelectReceiverAsync(Guid orderId)
|
|
{
|
|
try
|
|
{
|
|
var command = await _repository.GetByIdAsync(orderId);
|
|
if (command == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
var receivers = (await _repository.GetReceiverByCommmandIdAsync(orderId))
|
|
.OrderBy(x => x.Sequence)
|
|
.Select(r => new CommandReceiverResponse
|
|
{
|
|
RefRecordId = r.RefPlacementProfileId!.Value,
|
|
PersonalId = r.Id,
|
|
Sequence = r.Sequence,
|
|
IdCard = r.CitizenId,
|
|
Name = $"{r.Prefix!}{r.FirstName!} {r.LastName!}",
|
|
SelectStatus = true,
|
|
Education = "" // ยังหาไม่เจอว่าอยุ่ field ไหน
|
|
}).ToList();
|
|
|
|
// ให้ Update Salary เฉพาะของ Command 01-04
|
|
switch (command.CommandType.CommandCode.ToUpper())
|
|
{
|
|
case "C-PM-01":
|
|
case "C-PM-02":
|
|
case "C-PM-03":
|
|
case "C-PM-04":
|
|
{
|
|
foreach (var r in receivers)
|
|
{
|
|
var salary = await _repository.GetPlacementSalaryAsync(r.RefRecordId);
|
|
r.SalaryAmount = salary.SalaryAmount;
|
|
r.PositionSalaryAmount = salary.PositionSalaryAmount;
|
|
r.MonthSalaryAmount = salary.MonthSalaryAmount;
|
|
}
|
|
break;
|
|
}
|
|
case "C-PM-39":
|
|
{
|
|
foreach (var r in receivers)
|
|
{
|
|
var salary = await _repository.GetPlacementSalaryAsync(r.RefRecordId);
|
|
r.SalaryAmount = salary.SalaryAmount;
|
|
r.PositionSalaryAmount = salary.PositionSalaryAmount;
|
|
r.MonthSalaryAmount = salary.MonthSalaryAmount;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
foreach (var r in receivers)
|
|
{
|
|
var salary = await _repository.GetCommandReceiverSalary(r.PersonalId, r.SalaryAmount, r.MonthSalaryAmount, r.PositionSalaryAmount);
|
|
r.SalaryAmount = salary.SalaryAmount;
|
|
r.PositionSalaryAmount = salary.PositionSalaryAmount;
|
|
r.MonthSalaryAmount = salary.MonthSalaryAmount;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
return Success(receivers);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// บันทึกข้อมูลเลือกรายชื่อออกคำสั่ง ** ที่ได้เลือกเอาไว้แล้ว **
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("persons/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> SaveCommandSelectReceiverAsync([FromHeader] string authorization, Guid orderId, [FromBody] List<Guid> selected)
|
|
{
|
|
try
|
|
{
|
|
var token = string.Empty;
|
|
if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue))
|
|
{
|
|
// we have a valid AuthenticationHeaderValue that has the following details:
|
|
|
|
var scheme = headerValue.Scheme;
|
|
token = headerValue.Parameter;
|
|
|
|
// scheme will be "Bearer"
|
|
// parmameter will be the token itself.
|
|
}
|
|
|
|
await _repository.SaveSelectedReceiverAsync(orderId, selected, token);
|
|
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-27 : ลบข้อมูลเลือกรายชื่อออกคำสั่ง
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// ** ยังไม่ได้กรองหน่วยงาน **
|
|
/// </remarks>
|
|
/// <param name="personalId">Record Id ของผู้รับคำสั่งในรายการบัญชีแนบท้าย</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpDelete("persons/{personalId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> DeleteCommandReceiverAsync(Guid personalId)
|
|
{
|
|
try
|
|
{
|
|
var receiver = await _repository.DeleteCommandReceiverAsync(personalId);
|
|
return Success(receiver);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-28 : ข้อมูลเลือกรายชื่อส่งสำเนาคำสั่ง
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("copy-order/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> GetCommandDeploymentAsync(Guid orderId)
|
|
{
|
|
try
|
|
{
|
|
var deployments = (await _repository.GetDeploymentByCommandIdAsync(orderId))
|
|
.Select(x => new
|
|
{
|
|
personalId = x.Id,
|
|
sequence = x.Sequence,
|
|
selectStatus = true,
|
|
idCard = x.CitizenId,
|
|
name = $"{x.Prefix}{x.FirstName} {x.LastName}",
|
|
position = x.PositionName,
|
|
unit = x.OrganizationName,
|
|
emailChannel = x.IsSendMail,
|
|
inboxChannel = x.IsSendInbox
|
|
})
|
|
.ToList();
|
|
|
|
return Success(deployments);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-30 : popup - เลือกรายชื่อส่งสำเนาคำสั่ง
|
|
/// </summary>
|
|
/// <param name="organizationId">Record Id ของหน่วยงาน</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("copy-order/persons/{organizationId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> GetPeopleByOrganizationIdAsync(Guid organizationId)
|
|
{
|
|
try
|
|
{
|
|
var people = (await _repository.GetProfileByOrganizationIdAsync(organizationId))
|
|
.Select(x => new
|
|
{
|
|
profileId = x.Profile!.Id,
|
|
idCard = x.Profile!.CitizenId,
|
|
name = $"{x.Profile!.Prefix!.Name}{x.Profile!.FirstName} {x.Profile!.LastName}",
|
|
position = x.OrganizationPosition!.PositionMaster!.PositionPath!.Name,
|
|
unit = x.OrganizationPosition!.Organization!.OrganizationOrganization!.Name,
|
|
prefixId = x.Profile!.Prefix!.Id,
|
|
firstName = x.Profile!.FirstName,
|
|
lastName = x.Profile!.LastName
|
|
})
|
|
.ToList();
|
|
|
|
return Success(people);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-31 : เพิ่มรายชื่อคนที่ต้องการส่งสำเนาคำสั่ง
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("copy-order/persons/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> CreateCommandDeploymentAsync(Guid orderId, [FromBody] List<CreateCommandDeploymentRequest> req)
|
|
{
|
|
try
|
|
{
|
|
// transform req
|
|
var deploys = new List<CommandDeployment>();
|
|
foreach (var p in req)
|
|
{
|
|
deploys.Add(new CommandDeployment
|
|
{
|
|
CitizenId = p.CitizenId,
|
|
Prefix = p.Prefix,
|
|
FirstName = p.FirstName,
|
|
LastName = p.LastName,
|
|
OrganizationName = p.OrganizationName,
|
|
ReceiveUserId = p.ProfileId.ToString(),
|
|
PositionName = p.Position
|
|
});
|
|
}
|
|
|
|
await _repository.CreateCommandDeploymentAsync(orderId, deploys);
|
|
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-32 : บันทึกช่องทางการส่งสำเนาคำสั่ง
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("copy-order")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> UpdateCommandDeploymentAsync([FromBody] List<UpdateCommandDeploymentRequest> req)
|
|
{
|
|
try
|
|
{
|
|
// transform
|
|
var deploys = new List<CommandDeployment>();
|
|
foreach (var p in req)
|
|
{
|
|
var updated = await _repository.GetCommandDeploymentById(p.PersonalId);
|
|
updated!.IsSendInbox = p.InboxChannel;
|
|
updated!.IsSendMail = p.EmailChannel;
|
|
deploys.Add(updated);
|
|
}
|
|
|
|
await _repository.UpdatCommandDeploymentAsync(deploys);
|
|
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-33 : ลบรายชื่อคนที่ต้องการส่งสำเนาคำสั่ง
|
|
/// </summary>
|
|
/// <param name="personalId">Record Id ของผู้รับสำเนาคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpDelete("copy-order/{personalId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> DeleteCommandDeloymentAsync(Guid personalId)
|
|
{
|
|
try
|
|
{
|
|
await _repository.DeleteCommandDeploymentAsync(personalId);
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#region " Documents "
|
|
|
|
/// <summary>
|
|
/// Download เอกสารแนบ
|
|
/// </summary>
|
|
/// <param name="docId">Record Id ของเอกสารแนบ</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("download/attachment/{docId}")]
|
|
[AllowAnonymous]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> DownloadAttachment(Guid docId)
|
|
{
|
|
var now = DateTime.Now.ToString("yyyyMMdd-HHmmss");
|
|
var file = Path.Combine(_hostingEnvironment.WebRootPath, "tmp", $"tmp-{now}.pdf");
|
|
var file_copy = Path.Combine(_hostingEnvironment.WebRootPath, "tmp", $"tmp-{now}-copy.pdf");
|
|
|
|
try
|
|
{
|
|
var doc = await _minIOService.DownloadFileAsync(docId);
|
|
|
|
// Copy to File
|
|
System.IO.File.WriteAllBytes(file, doc.FileContent);
|
|
var watermark_text = "COPY COPY COPY COPY";
|
|
var fName = Path.GetFileName(file);
|
|
|
|
AddWatermark(file, file_copy, watermark_text);
|
|
|
|
using (var fileStream = new System.IO.FileStream(file_copy, FileMode.Open, FileAccess.Read))
|
|
{
|
|
using (var ms = new MemoryStream())
|
|
{
|
|
fileStream.CopyTo(ms);
|
|
ms.Flush();
|
|
return File(ms.ToArray(), "application/octet-stream", fName);
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
finally
|
|
{
|
|
if (System.IO.File.Exists(file))
|
|
System.IO.File.Delete(file);
|
|
|
|
if (System.IO.File.Exists(file_copy))
|
|
System.IO.File.Delete(file_copy);
|
|
}
|
|
}
|
|
|
|
|
|
[HttpGet("gen-payload/{orderId}")]
|
|
[AllowAnonymous]
|
|
public async Task<ActionResult<ResponseObject>> GetPayloadStr(Guid orderId)
|
|
{
|
|
try
|
|
{
|
|
var command = await _repository.GetByIdAsync(orderId);
|
|
if (command == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
// create command payload
|
|
var payload_attach = command.Documents
|
|
.Select(x => new PayloadAttachment
|
|
{
|
|
name = x.Category == "cover" ? "สำเนาคำสั่ง" : "สำเนาเอกสารแนบท้าย",
|
|
url = $"{_configuration["API"]}/order/download/attachment/{x.Document.Id}"
|
|
})
|
|
.ToList();
|
|
|
|
var payload = new CommandPayload()
|
|
{
|
|
attachments = payload_attach
|
|
};
|
|
|
|
var payload_str = JsonConvert.SerializeObject(payload);
|
|
|
|
return Success(payload_str);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// PM7-34 : ข้อมูลรายละเอียดคำสั่งและแนบท้าย
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("attachment/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> GetCommandAttatchmentAsync(Guid orderId)
|
|
{
|
|
try
|
|
{
|
|
var command = await _repository.GetByIdAsync(orderId);
|
|
if (command == null)
|
|
throw new Exception(GlobalMessages.CommandNotFound);
|
|
|
|
var documents = await _repository.GetCommandDocumentAsync(orderId);
|
|
var cover = documents.Where(x => x.Category.Trim().ToLower() == GlobalConstants.TYPE_COVER).FirstOrDefault();
|
|
var attach = documents.Where(x => x.Category.Trim().ToLower() == GlobalConstants.TYPE_ATTACHMENT).FirstOrDefault();
|
|
|
|
var result = new
|
|
{
|
|
orderNo = command.CommandNo,
|
|
orderYear = command.CommandYear,
|
|
signDate = command.CommandExcecuteDate,
|
|
orderFileUrl = cover == null ? null : await _documentService.ImagesPath(cover.Document.Id),
|
|
attachmentFileUrl = attach == null ? null : await _documentService.ImagesPath(attach.Document.Id),
|
|
};
|
|
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// PM7-35 : อัปโหลดไฟล์คำสั่ง
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("attachment/order-file/{orderId}"), DisableRequestSizeLimit]
|
|
[Consumes("multipart/form-data")]
|
|
[SwaggerOperation(
|
|
Summary = "Upload a file",
|
|
Description = "Upload a file using multipart/form-data",
|
|
OperationId = "UploadCommandCoverAsync"
|
|
//Tags = new[] { "File" }
|
|
)]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> UploadCommandCoverAsync(Guid orderId)
|
|
{
|
|
try
|
|
{
|
|
// check upload file
|
|
if (Request.Form.Files == null || Request.Form.Files.Count == 0)
|
|
{
|
|
return Error(GlobalMessages.NoFileToUpload);
|
|
}
|
|
|
|
var file = Request.Form.Files[0];
|
|
|
|
// get exit file
|
|
var docs = await _repository.GetExistDocument(orderId, GlobalConstants.TYPE_COVER);
|
|
|
|
// delete exist document from s3
|
|
foreach (var doc in docs)
|
|
{
|
|
await _documentService.DeleteFileAsync(doc.Document.Id);
|
|
}
|
|
|
|
// upload new document to s3
|
|
var cover = await _documentService.UploadFileAsync(file);
|
|
|
|
// create new CommandDocumentEntity
|
|
var commandDoc = new CommandDocument
|
|
{
|
|
Category = GlobalConstants.TYPE_COVER,
|
|
Document = cover,
|
|
};
|
|
|
|
// send to repo to save in database
|
|
await _repository.UploadDocument(orderId, GlobalConstants.TYPE_COVER, commandDoc);
|
|
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PM7-36 : อัปโหลดไฟล์เอกสารแนบท้าย
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("attachment/file/{orderId}"), DisableRequestSizeLimit]
|
|
[Consumes("multipart/form-data")]
|
|
[SwaggerOperation(
|
|
Summary = "Upload a file",
|
|
Description = "Upload a file using multipart/form-data",
|
|
OperationId = "UploadCommandAttachmentAsync"
|
|
//Tags = new[] { "File" }
|
|
)]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> UploadCommandAttachmentAsync(Guid orderId)
|
|
{
|
|
try
|
|
{
|
|
// check upload file
|
|
if (Request.Form.Files == null || Request.Form.Files.Count == 0)
|
|
{
|
|
return Error(GlobalMessages.NoFileToUpload);
|
|
}
|
|
|
|
var file = Request.Form.Files[0];
|
|
|
|
// get exit file
|
|
var docs = await _repository.GetExistDocument(orderId, GlobalConstants.TYPE_ATTACHMENT);
|
|
|
|
// delete exist document from s3
|
|
|
|
foreach (var doc in docs)
|
|
{
|
|
await _documentService.DeleteFileAsync(doc.Document.Id);
|
|
}
|
|
|
|
// upload new document to s3
|
|
var cover = await _documentService.UploadFileAsync(file);
|
|
|
|
// create new CommandDocumentEntity
|
|
var commandDoc = new CommandDocument
|
|
{
|
|
Category = GlobalConstants.TYPE_ATTACHMENT,
|
|
Document = cover,
|
|
};
|
|
|
|
// send to repo to save in database
|
|
await _repository.UploadDocument(orderId, GlobalConstants.TYPE_ATTACHMENT, commandDoc);
|
|
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// PM7-37 : บันทึกข้อมูลคำสั่งและแนบท้าย
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("attachment/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> UpdateCommandExecuteAsync(Guid orderId, [FromBody] UpdateCommandExecuteRequest req)
|
|
{
|
|
try
|
|
{
|
|
await _repository.UpdateCommandInfoAsync(orderId, req.OrderNo, req.OrderYear, req.SignDate);
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// อ่านข้อมูลเงินเดือนสำหรับผู้บรรจุ จากข้อมูลระบบสรรหา
|
|
/// </summary>
|
|
/// <param name="personalId">Record Id ของผู้รับคำสั่งในบัญชีแนบท้าย</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("salary/{personalId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> GetPlacementSalaryAsync(Guid personalId)
|
|
{
|
|
try
|
|
{
|
|
var record = await _repository.GetCommandReceiverAsync(personalId);
|
|
if (record == null)
|
|
{
|
|
throw new Exception(GlobalMessages.DataNotFound);
|
|
}
|
|
|
|
var data = new PlacementSalaryResponse();
|
|
|
|
switch (record.Command.CommandType.CommandCode.ToUpper())
|
|
{
|
|
case "C-PM-01":
|
|
case "C-PM-02":
|
|
case "C-PM-03":
|
|
case "C-PM-04":
|
|
data = await _repository.GetPlacementSalaryAsync(record!.RefPlacementProfileId!.Value);
|
|
break;
|
|
case "C-PM-39":
|
|
data = await _repository.GetPlacementSalaryAsync(record!.RefPlacementProfileId!.Value);
|
|
break;
|
|
default:
|
|
data = await _repository.GetCommandReceiverSalary(personalId, record.Amount, record.MouthSalaryAmount, record.PositionSalaryAmount);
|
|
break;
|
|
}
|
|
|
|
return Success(data);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// บันทึกข้อมูลเงินเดือนสำหรับผู้บรรจุ
|
|
/// </summary>
|
|
/// <param name="personalId">Record Id ของผู้รับคำสั่งในบัญชีแนบท้าย</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("salary/{personalId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> UpdatePlacementSalaryAsync(Guid personalId, [FromBody] UpdatePlacementSalaryRequest req)
|
|
{
|
|
try
|
|
{
|
|
var receiver = await _repository.GetCommandReceiverAsync(personalId);
|
|
|
|
if (receiver == null)
|
|
throw new Exception(GlobalMessages.DataNotFound);
|
|
|
|
switch (receiver.Command.CommandType.CommandCode.ToUpper())
|
|
{
|
|
case "C-PM-01":
|
|
case "C-PM-02":
|
|
case "C-PM-03":
|
|
case "C-PM-04":
|
|
await _repository.UpdatePlacementSalaryAsync(personalId, req);
|
|
return Success();
|
|
case "C-PM-39":
|
|
await _repository.UpdatePlacementSalaryAsync(personalId, req);
|
|
return Success();
|
|
default:
|
|
await _repository.UpdateCommandReceiverSalaryAsync(personalId, req);
|
|
return Success();
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// สลับลำดับข้อมูลในบัญชีแนบท้ายขึ้น
|
|
/// </summary>
|
|
/// <param name="personalId">Record Id ของผู้รับคำสั่งในบัญชีแนบท้าย</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("swap/up/{personalId}")]
|
|
public async Task<ActionResult<ResponseObject>> SwapUpReceiverOrderAsync(Guid personalId)
|
|
{
|
|
try
|
|
{
|
|
await _repository.SwapReceiverOrderAsync(personalId, "up");
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// สลับลำดับข้อมูลในบัญชีแนบท้ายลง
|
|
/// </summary>
|
|
/// <param name="personalId">Record Id ของผู้รับคำสั่งในบัญชีแนบท้าย</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("swap/down/{personalId}")]
|
|
public async Task<ActionResult<ResponseObject>> SwapDownReceiverOrderAsync(Guid personalId)
|
|
{
|
|
try
|
|
{
|
|
await _repository.SwapReceiverOrderAsync(personalId, "down");
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// ออกคำสั่ง
|
|
/// </summary>
|
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("execute/{orderId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> ExecuteCommandAsync([FromHeader] string authorization, Guid orderId)
|
|
{
|
|
try
|
|
{
|
|
var token = string.Empty;
|
|
if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue))
|
|
{
|
|
// we have a valid AuthenticationHeaderValue that has the following details:
|
|
|
|
var scheme = headerValue.Scheme;
|
|
token = headerValue.Parameter;
|
|
|
|
// scheme will be "Bearer"
|
|
// parmameter will be the token itself.
|
|
}
|
|
await _repository.ExecuteCommandAsync(orderId, token);
|
|
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// แสดงรายชื่อหน่วยงานสำหรับเลือกเพื่อออกคำสั่ง
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("organizations")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> GetCommandOrganizationAsync([FromHeader] string authorization)
|
|
{
|
|
try
|
|
{
|
|
var token = string.Empty;
|
|
if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue))
|
|
{
|
|
// we have a valid AuthenticationHeaderValue that has the following details:
|
|
|
|
var scheme = headerValue.Scheme;
|
|
token = headerValue.Parameter;
|
|
|
|
// scheme will be "Bearer"
|
|
// parmameter will be the token itself.
|
|
}
|
|
var data = await _repository.GetCommandOrgAsync(token);
|
|
|
|
return Success(data);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// แสดงชื่อผู้อนุมัติในรายการคำสั่ง
|
|
/// </summary>
|
|
/// <param name="ocId">Id ของหน่วยงานที่เลือกเพื่อออกคำสั่ง</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("approver/{ocId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> GetCommandOrganizationApproverAsync(Guid ocId)
|
|
{
|
|
try
|
|
{
|
|
var data = await _repository.GetOrgApproverAsync(ocId);
|
|
|
|
return Success(data);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// แสดงชื่อผู้เกี่ยวข้องกับคำสั่ง
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("search/profile/command")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> GetCommandProfileAsync([FromBody] SearchProfileCommandRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data = await _repository.GetCommandProfileAsync(req.CommandType, req.Year, req.Posno);
|
|
|
|
return Success(data);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// แสดงประวัติการออกคำสั่ง
|
|
/// </summary>
|
|
/// <param name="type">ประเภทระบบคำสั่ง</param>
|
|
/// <param name="profileId">Id ผู้ใช้งาน</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("history/{type}/{profileId}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> GetHistoryCommandByProfileAsync(string type, Guid profileId)
|
|
{
|
|
try
|
|
{
|
|
var data = await _repository.GetHistoryCommandByProfileAsync(type, profileId);
|
|
|
|
return Success(data);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// แสดงประวัติการออกคำสั่ง
|
|
/// </summary>
|
|
/// <param name="type">ประเภทระบบคำสั่ง</param>
|
|
/// <param name="profileId">Id ผู้ใช้งาน</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("historanfaskfa")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> DumpDB([FromHeader] string authorization)
|
|
{
|
|
try
|
|
{
|
|
var token = string.Empty;
|
|
if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue))
|
|
{
|
|
// we have a valid AuthenticationHeaderValue that has the following details:
|
|
|
|
var scheme = headerValue.Scheme;
|
|
token = headerValue.Parameter;
|
|
|
|
// scheme will be "Bearer"
|
|
// parmameter will be the token itself.
|
|
}
|
|
await _repository.DumpDB(token);
|
|
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|