3454 lines
158 KiB
C#
3454 lines
158 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 Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Swashbuckle.AspNetCore.Annotations;
|
|
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;
|
|
|
|
#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)
|
|
{
|
|
_repository = repository;
|
|
_context = context;
|
|
_documentService = documentService;
|
|
_httpContextAccessor = httpContextAccessor;
|
|
_placementRepository = placementRepository;
|
|
_prefixRepository = prefixRepository;
|
|
_commandTypeRepository = commandTypeRepository;
|
|
_commandStatusRepository = commandStatusRepository;
|
|
_userProfileRepository = userProfileRepository;
|
|
_emailSenderService = emailSenderService;
|
|
}
|
|
|
|
#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 Guid OcId
|
|
{
|
|
get
|
|
{
|
|
if (UserId != null || UserId != "")
|
|
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
|
else
|
|
return Guid.Empty;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region " Methods "
|
|
|
|
//[HttpGet("mail")]
|
|
//[AllowAnonymous]
|
|
//public IActionResult TestSendMail()
|
|
//{
|
|
// try
|
|
// {
|
|
// _emailSenderService.SendMail("test send mail", "test body", "suphonchai@frappet.com");
|
|
|
|
// return Ok();
|
|
// }
|
|
// catch
|
|
// {
|
|
// throw;
|
|
// }
|
|
//}
|
|
|
|
/// <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-18":
|
|
case "C-PM-19":
|
|
case "C-PM-20":
|
|
case "C-PM-21":
|
|
{
|
|
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
|
|
}).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,
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
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-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] 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,
|
|
};
|
|
|
|
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] 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;
|
|
|
|
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,
|
|
};
|
|
|
|
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;
|
|
|
|
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,
|
|
};
|
|
|
|
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;
|
|
|
|
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
|
|
|
|
#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() : await _placementRepository.GetQualifyingPlacementAsync();
|
|
|
|
|
|
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!.Value,
|
|
PersonalId = r.Id,
|
|
Sequence = r.Sequence,
|
|
IdCard = r.CitizenId,
|
|
Name = $"{r.Prefix!}{r.FirstName!} {r.LastName!}",
|
|
SelectStatus = existed.FirstOrDefault(x => x.RefPlacementProfileId!.Value == r.RefPlacementProfileId!.Value) != null,
|
|
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;
|
|
default:
|
|
{
|
|
foreach (var r in receivers)
|
|
{
|
|
var salary = await _repository.GetCommandReceiverSalary(r.PersonalId);
|
|
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;
|
|
}
|
|
default:
|
|
{
|
|
foreach (var r in receivers)
|
|
{
|
|
var salary = await _repository.GetCommandReceiverSalary(r.PersonalId);
|
|
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)
|
|
{
|
|
var prefix = await _prefixRepository.GetByIdAsync(p.PrefixId);
|
|
deploys.Add(new CommandDeployment
|
|
{
|
|
CitizenId = p.IdCard,
|
|
Prefix = prefix.Name,
|
|
FirstName = p.FirstName,
|
|
LastName = p.LastName,
|
|
OrganizationName = p.Unit,
|
|
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>
|
|
/// 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;
|
|
default:
|
|
data = await _repository.GetCommandReceiverSalary(personalId);
|
|
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();
|
|
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(Guid orderId)
|
|
{
|
|
try
|
|
{
|
|
await _repository.ExecuteCommandAsync(orderId);
|
|
|
|
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()
|
|
{
|
|
try
|
|
{
|
|
var data = await _repository.GetCommandOrgAsync();
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|