Merge branch 'develop' into working
This commit is contained in:
commit
9ff5725be4
18 changed files with 14169 additions and 72 deletions
|
|
@ -212,12 +212,12 @@ namespace BMA.EHR.Application.Repositories
|
|||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.InvalidCoinPeriod);
|
||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||
|
||||
if (oc == null)
|
||||
throw new Exception(GlobalMessages.InvalidOC);
|
||||
throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
var CurrentRetireDate = new DateTime(period.Year, 9, 30);
|
||||
|
||||
|
|
@ -607,12 +607,12 @@ namespace BMA.EHR.Application.Repositories
|
|||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.InvalidCoinPeriod);
|
||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||
|
||||
if (oc == null)
|
||||
throw new Exception(GlobalMessages.InvalidOC);
|
||||
throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
var CurrentRetireDate = new DateTime(period.Year, 9, 30);
|
||||
|
||||
|
|
@ -825,12 +825,12 @@ namespace BMA.EHR.Application.Repositories
|
|||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.InvalidCoinPeriod);
|
||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||
|
||||
if (oc == null)
|
||||
throw new Exception(GlobalMessages.InvalidOC);
|
||||
throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
var CurrentRetireDate = new DateTime(period.Year, 9, 30);
|
||||
|
||||
|
|
@ -1044,12 +1044,12 @@ namespace BMA.EHR.Application.Repositories
|
|||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.InvalidCoinPeriod);
|
||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||
|
||||
if (oc == null)
|
||||
throw new Exception(GlobalMessages.InvalidOC);
|
||||
throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
var CurrentRetireDate = new DateTime(period.Year, 9, 30);
|
||||
|
||||
|
|
@ -1366,12 +1366,12 @@ namespace BMA.EHR.Application.Repositories
|
|||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.InvalidCoinPeriod);
|
||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||
|
||||
if (oc == null)
|
||||
throw new Exception(GlobalMessages.InvalidOC);
|
||||
throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
var CurrentRetireDate = new DateTime(period.Year, 9, 30);
|
||||
|
||||
|
|
@ -1489,12 +1489,12 @@ namespace BMA.EHR.Application.Repositories
|
|||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.InvalidCoinPeriod);
|
||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||
|
||||
if (oc == null)
|
||||
throw new Exception(GlobalMessages.InvalidOC);
|
||||
throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
var CurrentRetireDate = new DateTime(period.Year, 9, 30);
|
||||
|
||||
|
|
@ -1793,12 +1793,12 @@ namespace BMA.EHR.Application.Repositories
|
|||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.InvalidCoinPeriod);
|
||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||
|
||||
if (oc == null)
|
||||
throw new Exception(GlobalMessages.InvalidOC);
|
||||
throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
var CurrentRetireDate = new DateTime(period.Year, 9, 30);
|
||||
|
||||
|
|
@ -2017,12 +2017,12 @@ namespace BMA.EHR.Application.Repositories
|
|||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.InvalidCoinPeriod);
|
||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||
|
||||
if (oc == null)
|
||||
throw new Exception(GlobalMessages.InvalidOC);
|
||||
throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
var CurrentRetireDate = new DateTime(period.Year, 9, 30);
|
||||
|
||||
|
|
@ -2329,12 +2329,12 @@ namespace BMA.EHR.Application.Repositories
|
|||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.InvalidCoinPeriod);
|
||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||
|
||||
if (oc == null)
|
||||
throw new Exception(GlobalMessages.InvalidOC);
|
||||
throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
var CurrentRetireDate = new DateTime(period.Year, 9, 30);
|
||||
|
||||
|
|
@ -2673,12 +2673,12 @@ namespace BMA.EHR.Application.Repositories
|
|||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.InvalidCoinPeriod);
|
||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||
|
||||
if (oc == null)
|
||||
throw new Exception(GlobalMessages.InvalidOC);
|
||||
throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
var CurrentRetireDate = new DateTime(period.Year, 9, 30);
|
||||
|
||||
|
|
@ -3011,12 +3011,12 @@ namespace BMA.EHR.Application.Repositories
|
|||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.InvalidCoinPeriod);
|
||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||
|
||||
if (oc == null)
|
||||
throw new Exception(GlobalMessages.InvalidOC);
|
||||
throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
var CurrentRetireDate = new DateTime(period.Year, 9, 30);
|
||||
|
||||
|
|
@ -3228,12 +3228,12 @@ namespace BMA.EHR.Application.Repositories
|
|||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.InvalidCoinPeriod);
|
||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||
|
||||
if (oc == null)
|
||||
throw new Exception(GlobalMessages.InvalidOC);
|
||||
throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
var CurrentRetireDate = new DateTime(period.Year, 9, 30);
|
||||
|
||||
|
|
@ -3541,12 +3541,12 @@ namespace BMA.EHR.Application.Repositories
|
|||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.InvalidCoinPeriod);
|
||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||
|
||||
if (oc == null)
|
||||
throw new Exception(GlobalMessages.InvalidOC);
|
||||
throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
var CurrentRetireDate = new DateTime(period.Year, 9, 30);
|
||||
|
||||
|
|
@ -3826,12 +3826,12 @@ namespace BMA.EHR.Application.Repositories
|
|||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.InvalidCoinPeriod);
|
||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||
|
||||
if (oc == null)
|
||||
throw new Exception(GlobalMessages.InvalidOC);
|
||||
throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
var CurrentRetireDate = new DateTime(period.Year, 9, 30);
|
||||
|
||||
|
|
@ -4147,12 +4147,12 @@ namespace BMA.EHR.Application.Repositories
|
|||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.InvalidCoinPeriod);
|
||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||
|
||||
if (oc == null)
|
||||
throw new Exception(GlobalMessages.InvalidOC);
|
||||
throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
var CurrentRetireDate = new DateTime(period.Year, 9, 30);
|
||||
|
||||
|
|
@ -4689,12 +4689,12 @@ namespace BMA.EHR.Application.Repositories
|
|||
// var period = await _dbContext.Set<InsigniaPeriods>().FirstOrDefault(p => p.Id == periodId);
|
||||
|
||||
// if (period == null)
|
||||
// throw new Exception(GlobalMessages.InvalidCoinPeriod);
|
||||
// throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
// var oc = await _dbContext.Set<OrganizationCharts>().FirstOrDefault(x => x.OCId == ocId);
|
||||
|
||||
// if (oc == null)
|
||||
// throw new Exception(GlobalMessages.InvalidOC);
|
||||
// throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
// var result = await _dbContext.Set<Profile>()
|
||||
// .Include(p => p.Position)
|
||||
|
|
@ -4970,7 +4970,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
// var req = await _dbContext.Set<InsigniaRequests>().FirstOrDefault(x => x.Id == id);
|
||||
|
||||
// if (req == null)
|
||||
// throw new Exception(GlobalMessages.InvalidInsigniaRequest);
|
||||
// throw new Exception(GlobalMessages.InsigniaNotFound);
|
||||
|
||||
// var profile = await _dbContext.Set<InsigniaRequestsProfiles>().AsQueryable()
|
||||
// .Include(x => x.RequestInsignia)
|
||||
|
|
@ -5060,12 +5060,12 @@ namespace BMA.EHR.Application.Repositories
|
|||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.InvalidCoinPeriod);
|
||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||
|
||||
if (oc == null)
|
||||
throw new Exception(GlobalMessages.InvalidOC);
|
||||
throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
var req = new InsigniaRequest
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,20 +10,16 @@ namespace BMA.EHR.Domain.Models.Insignias
|
|||
{
|
||||
[Required, MaxLength(200)]
|
||||
public string Name { get; set; }
|
||||
|
||||
public int Year { get; set; }
|
||||
|
||||
public DateTime StartDate { get; set; }
|
||||
|
||||
public DateTime EndDate { get; set; }
|
||||
|
||||
[MaxLength(50)]
|
||||
public string Amount { get; set; }
|
||||
|
||||
[MaxLength(10)]
|
||||
public string Type { get; set; }
|
||||
public Document? ReliefDoc { get; set; }
|
||||
|
||||
[Comment("สถานะการใช้งาน")]
|
||||
public bool IsActive { get; set; } = true;
|
||||
public virtual List<InsigniaRequest> InsigniaRequests { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
28
BMA.EHR.Domain/Models/Retirement/RetirementDeceased.cs
Normal file
28
BMA.EHR.Domain/Models/Retirement/RetirementDeceased.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using BMA.EHR.Domain.Models.Base;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Domain.Models.Organizations;
|
||||
using BMA.EHR.Domain.Models.Documents;
|
||||
using BMA.EHR.Domain.Models.HR;
|
||||
|
||||
namespace BMA.EHR.Domain.Models.Retirement
|
||||
{
|
||||
public class RetirementDeceased : EntityBase
|
||||
{
|
||||
[Comment("ใบมรณบัตร")]
|
||||
public Document? Document { get; set; }
|
||||
[Comment("เลขที่ใบมรณบัตร")]
|
||||
public string? Number { get; set; } = string.Empty;
|
||||
[Comment("วันที่เสียชีวิต")]
|
||||
public DateTime? Date { get; set; }
|
||||
[Comment("สถานที่ออกใบมรณบัตร")]
|
||||
public string? Location { get; set; } = string.Empty;
|
||||
[Comment("เหตุผลการเสียชีวิต")]
|
||||
public string? Reason { get; set; } = string.Empty;
|
||||
[Comment("Id ผู้ถึงแก่กรรม")]
|
||||
public Profile Profile { get; set; }
|
||||
[Comment("สถานะการใช้งาน")]
|
||||
public bool IsActive { get; set; } = true;
|
||||
}
|
||||
}
|
||||
40
BMA.EHR.Domain/Models/Retirement/RetirementResign.cs
Normal file
40
BMA.EHR.Domain/Models/Retirement/RetirementResign.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using BMA.EHR.Domain.Models.Base;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Domain.Models.Organizations;
|
||||
using BMA.EHR.Domain.Models.Documents;
|
||||
using BMA.EHR.Domain.Models.HR;
|
||||
|
||||
namespace BMA.EHR.Domain.Models.Retirement
|
||||
{
|
||||
public class RetirementResign : EntityBase
|
||||
{
|
||||
[Comment("สถานที่ยื่นขอลาออกราชการ")]
|
||||
public string? Location { get; set; } = string.Empty;
|
||||
[Comment("วันที่ยื่นขอออกราชการ")]
|
||||
public DateTime? SendDate { get; set; }
|
||||
|
||||
[Comment("วันที่ขอออกราชการ")]
|
||||
public DateTime? ActiveDate { get; set; }
|
||||
[Comment("เหตุผลที่ลาออกจากราชการ")]
|
||||
public string? Reason { get; set; } = string.Empty;
|
||||
[Comment("Id ผู้ลาออก")]
|
||||
public Profile Profile { get; set; }
|
||||
[Comment("Id ประเภทตำแหน่ง")]
|
||||
public PositionType? PositionType { get; set; }
|
||||
[Comment("Id สายงาน")]
|
||||
public PositionLine? PositionLine { get; set; }
|
||||
|
||||
[Comment("Id ระดับ")]
|
||||
public PositionLevel? PositionLevel { get; set; }
|
||||
[Comment("Id ตำแหน่งทางการบริหาร")]
|
||||
public PositionExecutive? PositionExecutive { get; set; }
|
||||
[Comment("Id สังกัด")]
|
||||
public OrganizationOrganization? OrganizationOrganization { get; set; }
|
||||
[Comment("สถานะลาออก")]
|
||||
public string? Status { get; set; } = "PENDING";
|
||||
[Comment("สถานะการใช้งาน")]
|
||||
public bool IsActive { get; set; } = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -70,18 +70,17 @@
|
|||
#endregion
|
||||
|
||||
#region " Insignia "
|
||||
public static readonly string InvalidInsigniaRequest = "ไม่พบข้อมูลการยื่นขอพระราชทานเครื่องราชย์ของหน่วยงานที่ระบุ!!";
|
||||
|
||||
public static readonly string InvalidInsigniaPeriod = "ไม่พบรอบการยื่นขอพระราชทานเครื่องราชย์อิสริยาภรณ์";
|
||||
|
||||
public static readonly string InvalidCoinPeriod = "ไม่พบรอบการขอพระราชทานเหรียญจักรพรรดิมาลาที่ระบุ!!";
|
||||
|
||||
public static readonly string InvalidOC = "ไม่พบหน่วยงานที่ระบุในระบบ";
|
||||
public static readonly string InsigniaRequestNotFound = "ไม่พบข้อมูลการยื่นขอพระราชทานเครื่องราชย์ของหน่วยงานที่ระบุ!!";
|
||||
public static readonly string InsigniaPeriodNotFound = "ไม่พบรอบการยื่นขอพระราชทานเครื่องราชย์อิสริยาภรณ์";
|
||||
public static readonly string CoinPeriodNotFound = "ไม่พบรอบการขอพระราชทานเหรียญจักรพรรดิมาลาที่ระบุ!!";
|
||||
public static readonly string OCNotFound = "ไม่พบหน่วยงานที่ระบุในระบบ";
|
||||
#endregion
|
||||
|
||||
#region " Retirement "
|
||||
public static readonly string InvalidRetirementRequest = "ไม่พบข้อมูลการประกาศเกษียณอายุราชการ";
|
||||
public static readonly string InvalidRetirementHistoryRequest = "ไม่พบข้อมูลประวัติการประกาศเกษียณอายุราชการ";
|
||||
public static readonly string RetirementNotFound = "ไม่พบข้อมูลการประกาศเกษียณอายุราชการ";
|
||||
public static readonly string RetirementHistoryNotFound = "ไม่พบข้อมูลประวัติการประกาศเกษียณอายุราชการ";
|
||||
public static readonly string RetirementResignNotFound = "ไม่พบข้อมูลการคำขอลาออก";
|
||||
public static readonly string RetirementDeceasedNotFound = "ไม่พบข้อมูลบันทึกเวียนแจ้งการถึงแก่กรรม";
|
||||
#endregion
|
||||
|
||||
#region " Command "
|
||||
|
|
|
|||
12943
BMA.EHR.Infrastructure/Migrations/20230808040745_add table RetirementDeceased.Designer.cs
generated
Normal file
12943
BMA.EHR.Infrastructure/Migrations/20230808040745_add table RetirementDeceased.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,188 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class addtableRetirementDeceased : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsActive",
|
||||
table: "InsigniaPeriods",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false,
|
||||
comment: "สถานะการใช้งาน");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RetirementDeceaseds",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
|
||||
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
|
||||
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
DocumentId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||
Number = table.Column<string>(type: "longtext", nullable: true, comment: "เลขที่ใบมรณบัตร")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Date = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่เสียชีวิต"),
|
||||
Location = table.Column<string>(type: "longtext", nullable: true, comment: "สถานที่ออกใบมรณบัตร")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Reason = table.Column<string>(type: "longtext", nullable: true, comment: "เหตุผลการเสียชีวิต")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "สถานะการใช้งาน")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RetirementDeceaseds", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_RetirementDeceaseds_Documents_DocumentId",
|
||||
column: x => x.DocumentId,
|
||||
principalTable: "Documents",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_RetirementDeceaseds_Profiles_ProfileId",
|
||||
column: x => x.ProfileId,
|
||||
principalTable: "Profiles",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RetirementResigns",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
|
||||
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
|
||||
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Location = table.Column<string>(type: "longtext", nullable: true, comment: "สถานที่ยื่นขอลาออกราชการ")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
SendDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่ยื่นขอออกราชการ"),
|
||||
ActiveDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่ขอออกราชการ"),
|
||||
Reason = table.Column<string>(type: "longtext", nullable: true, comment: "เหตุผลที่ลาออกจากราชการ")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
PositionTypeId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||
PositionLineId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||
PositionLevelId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||
PositionExecutiveId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||
OrganizationOrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||
Status = table.Column<string>(type: "longtext", nullable: true, comment: "สถานะลาออก")
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "สถานะการใช้งาน")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RetirementResigns", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_RetirementResigns_OrganizationOrganizations_OrganizationOrga~",
|
||||
column: x => x.OrganizationOrganizationId,
|
||||
principalTable: "OrganizationOrganizations",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_RetirementResigns_PositionExecutives_PositionExecutiveId",
|
||||
column: x => x.PositionExecutiveId,
|
||||
principalTable: "PositionExecutives",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_RetirementResigns_PositionLevels_PositionLevelId",
|
||||
column: x => x.PositionLevelId,
|
||||
principalTable: "PositionLevels",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_RetirementResigns_PositionLines_PositionLineId",
|
||||
column: x => x.PositionLineId,
|
||||
principalTable: "PositionLines",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_RetirementResigns_PositionTypes_PositionTypeId",
|
||||
column: x => x.PositionTypeId,
|
||||
principalTable: "PositionTypes",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_RetirementResigns_Profiles_ProfileId",
|
||||
column: x => x.ProfileId,
|
||||
principalTable: "Profiles",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RetirementDeceaseds_DocumentId",
|
||||
table: "RetirementDeceaseds",
|
||||
column: "DocumentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RetirementDeceaseds_ProfileId",
|
||||
table: "RetirementDeceaseds",
|
||||
column: "ProfileId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RetirementResigns_OrganizationOrganizationId",
|
||||
table: "RetirementResigns",
|
||||
column: "OrganizationOrganizationId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RetirementResigns_PositionExecutiveId",
|
||||
table: "RetirementResigns",
|
||||
column: "PositionExecutiveId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RetirementResigns_PositionLevelId",
|
||||
table: "RetirementResigns",
|
||||
column: "PositionLevelId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RetirementResigns_PositionLineId",
|
||||
table: "RetirementResigns",
|
||||
column: "PositionLineId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RetirementResigns_PositionTypeId",
|
||||
table: "RetirementResigns",
|
||||
column: "PositionTypeId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RetirementResigns_ProfileId",
|
||||
table: "RetirementResigns",
|
||||
column: "ProfileId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "RetirementDeceaseds");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RetirementResigns");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsActive",
|
||||
table: "InsigniaPeriods");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5131,6 +5131,10 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.Property<DateTime>("EndDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasComment("สถานะการใช้งาน");
|
||||
|
||||
b.Property<string>("LastUpdateFullName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
|
|
@ -10887,6 +10891,88 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.ToTable("PlacementTypes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementDeceased", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)")
|
||||
.HasColumnOrder(0)
|
||||
.HasComment("PrimaryKey")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnOrder(100)
|
||||
.HasComment("สร้างข้อมูลเมื่อ");
|
||||
|
||||
b.Property<string>("CreatedFullName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)")
|
||||
.HasColumnOrder(104)
|
||||
.HasComment("ชื่อ User ที่สร้างข้อมูล");
|
||||
|
||||
b.Property<string>("CreatedUserId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(40)
|
||||
.HasColumnType("varchar(40)")
|
||||
.HasColumnOrder(101)
|
||||
.HasComment("User Id ที่สร้างข้อมูล");
|
||||
|
||||
b.Property<DateTime?>("Date")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasComment("วันที่เสียชีวิต");
|
||||
|
||||
b.Property<Guid?>("DocumentId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasComment("สถานะการใช้งาน");
|
||||
|
||||
b.Property<string>("LastUpdateFullName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)")
|
||||
.HasColumnOrder(105)
|
||||
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
|
||||
|
||||
b.Property<string>("LastUpdateUserId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(40)
|
||||
.HasColumnType("varchar(40)")
|
||||
.HasColumnOrder(103)
|
||||
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
|
||||
|
||||
b.Property<DateTime?>("LastUpdatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnOrder(102)
|
||||
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
|
||||
|
||||
b.Property<string>("Location")
|
||||
.HasColumnType("longtext")
|
||||
.HasComment("สถานที่ออกใบมรณบัตร");
|
||||
|
||||
b.Property<string>("Number")
|
||||
.HasColumnType("longtext")
|
||||
.HasComment("เลขที่ใบมรณบัตร");
|
||||
|
||||
b.Property<Guid>("ProfileId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Reason")
|
||||
.HasColumnType("longtext")
|
||||
.HasComment("เหตุผลการเสียชีวิต");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DocumentId");
|
||||
|
||||
b.HasIndex("ProfileId");
|
||||
|
||||
b.ToTable("RetirementDeceaseds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementPeriod", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
|
@ -11115,6 +11201,112 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.ToTable("RetirementProfiles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResign", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)")
|
||||
.HasColumnOrder(0)
|
||||
.HasComment("PrimaryKey")
|
||||
.HasAnnotation("Relational:JsonPropertyName", "id");
|
||||
|
||||
b.Property<DateTime?>("ActiveDate")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasComment("วันที่ขอออกราชการ");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnOrder(100)
|
||||
.HasComment("สร้างข้อมูลเมื่อ");
|
||||
|
||||
b.Property<string>("CreatedFullName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)")
|
||||
.HasColumnOrder(104)
|
||||
.HasComment("ชื่อ User ที่สร้างข้อมูล");
|
||||
|
||||
b.Property<string>("CreatedUserId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(40)
|
||||
.HasColumnType("varchar(40)")
|
||||
.HasColumnOrder(101)
|
||||
.HasComment("User Id ที่สร้างข้อมูล");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasComment("สถานะการใช้งาน");
|
||||
|
||||
b.Property<string>("LastUpdateFullName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)")
|
||||
.HasColumnOrder(105)
|
||||
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
|
||||
|
||||
b.Property<string>("LastUpdateUserId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(40)
|
||||
.HasColumnType("varchar(40)")
|
||||
.HasColumnOrder(103)
|
||||
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
|
||||
|
||||
b.Property<DateTime?>("LastUpdatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnOrder(102)
|
||||
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
|
||||
|
||||
b.Property<string>("Location")
|
||||
.HasColumnType("longtext")
|
||||
.HasComment("สถานที่ยื่นขอลาออกราชการ");
|
||||
|
||||
b.Property<Guid?>("OrganizationOrganizationId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("PositionExecutiveId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("PositionLevelId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("PositionLineId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("PositionTypeId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("ProfileId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Reason")
|
||||
.HasColumnType("longtext")
|
||||
.HasComment("เหตุผลที่ลาออกจากราชการ");
|
||||
|
||||
b.Property<DateTime?>("SendDate")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasComment("วันที่ยื่นขอออกราชการ");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.HasColumnType("longtext")
|
||||
.HasComment("สถานะลาออก");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrganizationOrganizationId");
|
||||
|
||||
b.HasIndex("PositionExecutiveId");
|
||||
|
||||
b.HasIndex("PositionLevelId");
|
||||
|
||||
b.HasIndex("PositionLineId");
|
||||
|
||||
b.HasIndex("PositionTypeId");
|
||||
|
||||
b.HasIndex("ProfileId");
|
||||
|
||||
b.ToTable("RetirementResigns");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.Command", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Domain.Models.Commands.Core.CommandStatus", "CommandStatus")
|
||||
|
|
@ -12433,6 +12625,23 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.Navigation("PlacementTransfer");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementDeceased", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document")
|
||||
.WithMany()
|
||||
.HasForeignKey("DocumentId");
|
||||
|
||||
b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProfileId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Document");
|
||||
|
||||
b.Navigation("Profile");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementPeriodHistory", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementPeriod", "RetirementPeriod")
|
||||
|
|
@ -12463,6 +12672,47 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.Navigation("RetirementPeriod");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResign", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationOrganization", "OrganizationOrganization")
|
||||
.WithMany()
|
||||
.HasForeignKey("OrganizationOrganizationId");
|
||||
|
||||
b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionExecutive", "PositionExecutive")
|
||||
.WithMany()
|
||||
.HasForeignKey("PositionExecutiveId");
|
||||
|
||||
b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionLevel", "PositionLevel")
|
||||
.WithMany()
|
||||
.HasForeignKey("PositionLevelId");
|
||||
|
||||
b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionLine", "PositionLine")
|
||||
.WithMany()
|
||||
.HasForeignKey("PositionLineId");
|
||||
|
||||
b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionType", "PositionType")
|
||||
.WithMany()
|
||||
.HasForeignKey("PositionTypeId");
|
||||
|
||||
b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProfileId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("OrganizationOrganization");
|
||||
|
||||
b.Navigation("PositionExecutive");
|
||||
|
||||
b.Navigation("PositionLevel");
|
||||
|
||||
b.Navigation("PositionLine");
|
||||
|
||||
b.Navigation("PositionType");
|
||||
|
||||
b.Navigation("Profile");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.Command", b =>
|
||||
{
|
||||
b.Navigation("Deployments");
|
||||
|
|
|
|||
|
|
@ -306,6 +306,8 @@ namespace BMA.EHR.Infrastructure.Persistence
|
|||
public DbSet<RetirementPeriod> RetirementPeriods { get; set; }
|
||||
|
||||
public DbSet<RetirementProfile> RetirementProfiles { get; set; }
|
||||
public DbSet<RetirementDeceased> RetirementDeceaseds { get; set; }
|
||||
public DbSet<RetirementResign> RetirementResigns { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
period_end = p.EndDate,
|
||||
period_status = _repository.CalStatusByDate(p.StartDate, p.EndDate, p.Year.ToString()),
|
||||
period_year = p.Year,
|
||||
period_isActive = p.IsActive,
|
||||
period_doc = p.ReliefDoc == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ReliefDoc.Id,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
|
@ -84,6 +85,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
period_end = insigniaPeriod.period_end,
|
||||
period_status = insigniaPeriod.period_status,
|
||||
period_year = insigniaPeriod.period_year,
|
||||
period_isActive = insigniaPeriod.period_isActive,
|
||||
period_doc = insigniaPeriod.period_doc == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(insigniaPeriod.period_doc),
|
||||
};
|
||||
data.Add(_data);
|
||||
|
|
@ -115,6 +117,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
period_end = p.EndDate,
|
||||
period_status = _repository.CalStatusByDate(p.StartDate, p.EndDate, p.Year.ToString()),
|
||||
period_year = p.Year,
|
||||
period_isActive = p.IsActive,
|
||||
period_doc = p.ReliefDoc == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ReliefDoc.Id,
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
|
@ -130,6 +133,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
period_end = data.period_end,
|
||||
period_status = data.period_status,
|
||||
period_year = data.period_year,
|
||||
period_isActive = data.period_isActive,
|
||||
period_doc = data.period_doc == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.period_doc),
|
||||
};
|
||||
|
||||
|
|
@ -162,6 +166,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
EndDate = Request.Form.ContainsKey("EndDate") ? DateTime.Parse(Request.Form["EndDate"]) : DateTime.Now,
|
||||
Amount = Request.Form.ContainsKey("Amount") ? Request.Form["Amount"] : "",
|
||||
Type = type.Trim().ToUpper(),
|
||||
IsActive = true,
|
||||
CreatedUserId = FullName ?? "",
|
||||
CreatedFullName = UserId ?? "System Administrator",
|
||||
CreatedAt = DateTime.Now,
|
||||
|
|
|
|||
|
|
@ -457,7 +457,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
else
|
||||
return Error(GlobalMessages.InvalidInsigniaRequest);
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -469,10 +469,10 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
{
|
||||
var result = await _repository.GetInsigniaRequest(Royal_Type, ocId);
|
||||
if (result == null)
|
||||
return Error(GlobalMessages.InvalidInsigniaRequest);
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
|
||||
if (requestId == null)
|
||||
return Error(GlobalMessages.InvalidInsigniaRequest);
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
|
||||
if (requestNew != null)
|
||||
{
|
||||
|
|
@ -481,7 +481,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
else
|
||||
return Error(GlobalMessages.InvalidInsigniaRequest);
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
}
|
||||
|
||||
[HttpPost("status/director/reject/{ocId:length(36)}")]
|
||||
|
|
@ -489,10 +489,10 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
{
|
||||
var result = await _repository.GetInsigniaRequest(Royal_Type, ocId);
|
||||
if (result == null)
|
||||
return Error(GlobalMessages.InvalidInsigniaRequest);
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
|
||||
if (requestId == null)
|
||||
return Error(GlobalMessages.InvalidInsigniaRequest);
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
|
||||
if (requestNew != null)
|
||||
{
|
||||
|
|
@ -501,7 +501,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
else
|
||||
return Error(GlobalMessages.InvalidInsigniaRequest);
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
|
|
@ -11,7 +9,6 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Controllers
|
||||
{
|
||||
|
|
@ -87,6 +84,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
|
||||
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
|
||||
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
|
||||
OrganizationName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationOrganization == null ? null : p.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
|
||||
OrganizationShortName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationShortName == null ? null : p.OrganizationPosition.Organization.OrganizationShortName.Name)),////
|
||||
p.IsActive,
|
||||
p.CreatedAt,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
|
|
@ -11,7 +9,6 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Controllers
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
|
|
@ -11,10 +9,7 @@ using Microsoft.AspNetCore.Authorization;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace BMA.EHR.Retirement.Service.Controllers
|
||||
{
|
||||
|
|
@ -363,7 +358,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
var retireOld = await _context.RetirementPeriods
|
||||
.FirstOrDefaultAsync(x => x.Id == req.RetireHistoryId);
|
||||
if (retireOld == null)
|
||||
return Error(GlobalMessages.InvalidRetirementRequest, 404);
|
||||
return Error(GlobalMessages.RetirementNotFound, 404);
|
||||
var profileOlds = await _context.RetirementProfiles.AsQueryable()
|
||||
.Where(x => x.RetirementPeriod == retireOld)
|
||||
.ToListAsync();
|
||||
|
|
@ -441,7 +436,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
var profileHistorys = await _context.RetirementPeriodHistorys.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == retireId);
|
||||
if (profileHistorys == null)
|
||||
return Error(GlobalMessages.InvalidRetirementHistoryRequest, 404);
|
||||
return Error(GlobalMessages.RetirementHistoryNotFound, 404);
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
var url = $"https://s3cluster.frappet.com/bma-ehr-fpt/{profileHistorys.ProfileFile}.json";
|
||||
|
|
@ -526,7 +521,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
.ThenInclude(x => x.Profile)
|
||||
.FirstOrDefaultAsync(x => x.Id == retireId);
|
||||
if (retire == null)
|
||||
return Error(GlobalMessages.InvalidRetirementRequest, 404);
|
||||
return Error(GlobalMessages.RetirementNotFound, 404);
|
||||
if (retire.RetirementProfiles.Where(x => x.Profile == profile).Count() > 0)
|
||||
return Error("บุคคลนี้ได้ทำการเลือกไว้อยู่แล้ว");
|
||||
foreach (var retire_profile in retire.RetirementProfiles)
|
||||
|
|
@ -671,7 +666,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
var retire = await _context.RetirementPeriods
|
||||
.FirstOrDefaultAsync(x => x.Id == retireId);
|
||||
if (retire == null)
|
||||
return Error(GlobalMessages.InvalidRetirementRequest, 404);
|
||||
return Error(GlobalMessages.RetirementNotFound, 404);
|
||||
|
||||
await GenOrderByYear(retire.Id);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,310 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using BMA.EHR.Retirement.Service.Requests;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace BMA.EHR.Retirement.Service.Controllers
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/retirement/deceased")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
[Authorize]
|
||||
[SwaggerTag("ระบบแจ้งการถึงแก่กรรม")]
|
||||
public class RetirementDeceasedController : BaseController
|
||||
{
|
||||
private readonly RetirementRepository _repository;
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public RetirementDeceasedController(RetirementRepository repository,
|
||||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_repository = repository;
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
||||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// list รายการบันทึกเวียนแจ้งการถึงแก่กรรม
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet()]
|
||||
public async Task<ActionResult<ResponseObject>> GetList()
|
||||
{
|
||||
|
||||
var retirementDeceaseds = await _context.RetirementDeceaseds.AsQueryable()
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||
p.Profile.FirstName,
|
||||
p.Profile.LastName,
|
||||
PositionType = p.Profile.PositionType == null ? null : p.Profile.PositionType.Name,
|
||||
p.Profile.PositionLine,
|
||||
// PositionLine = p.Profile.PositionLine == null ? null : p.Profile.PositionLine.Name,
|
||||
PositionLevel = p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name,
|
||||
p.Profile.PositionExecutive,
|
||||
// PositionExecutive = p.Profile.PositionExecutive == null ? null : p.Profile.PositionExecutive.Name,
|
||||
Organization = p.Profile.Oc,
|
||||
// Organization = p.Profile.Oc == null ? null : p.Profile.Oc.Name,
|
||||
p.Number,
|
||||
p.Date,
|
||||
p.Location,
|
||||
p.Reason,
|
||||
FileName = p.Document == null ? null : p.Document.FileName,
|
||||
PathName = p.Document == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Document.Id,
|
||||
p.IsActive,
|
||||
p.CreatedAt,
|
||||
})
|
||||
.ToListAsync();
|
||||
var _retirementDeceaseds = new List<dynamic>();
|
||||
foreach (var data in retirementDeceaseds)
|
||||
{
|
||||
var _data = new
|
||||
{
|
||||
data.Id,
|
||||
data.Prefix,
|
||||
data.FirstName,
|
||||
data.LastName,
|
||||
data.PositionExecutive,
|
||||
data.PositionType,
|
||||
data.PositionLine,
|
||||
data.PositionLevel,
|
||||
data.Organization,
|
||||
data.Number,
|
||||
data.Date,
|
||||
data.Location,
|
||||
data.Reason,
|
||||
data.FileName,
|
||||
PathName = data.PathName == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.PathName),
|
||||
data.IsActive,
|
||||
data.CreatedAt,
|
||||
};
|
||||
_retirementDeceaseds.Add(_data);
|
||||
}
|
||||
|
||||
return Success(_retirementDeceaseds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get รายละเอียดบันทึกเวียนแจ้งการถึงแก่กรรม
|
||||
/// </summary>
|
||||
/// <param name="id">Id การถึงแก่กรรม</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetDetailByUser(Guid id)
|
||||
{
|
||||
var data = await _context.RetirementDeceaseds.AsQueryable()
|
||||
.Where(x => x.Id == id)
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
|
||||
p.Profile.FirstName,
|
||||
p.Profile.LastName,
|
||||
PositionType = p.Profile.PositionType == null ? null : p.Profile.PositionType.Name,
|
||||
PositionTypeId = p.Profile.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.PositionType.Id,
|
||||
p.Profile.PositionLine,
|
||||
p.Profile.PositionLineId,
|
||||
// PositionLine = p.Profile.PositionLine == null ? null : p.Profile.PositionLine.Name,
|
||||
PositionLevel = p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name,
|
||||
PositionLevelId = p.Profile.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.PositionLevel.Id,
|
||||
p.Profile.PositionExecutive,
|
||||
p.Profile.PositionExecutiveId,
|
||||
// PositionExecutive = p.Profile.PositionExecutive == null ? null : p.Profile.PositionExecutive.Name,
|
||||
Organization = p.Profile.Oc,
|
||||
OrganizationId = p.Profile.OcId,
|
||||
// Organization = p.Profile.Oc == null ? null : p.Profile.Oc.Name,
|
||||
p.Number,
|
||||
p.Date,
|
||||
p.Location,
|
||||
p.Reason,
|
||||
FileName = p.Document == null ? null : p.Document.FileName,
|
||||
PathName = p.Document == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Document.Id,
|
||||
p.IsActive,
|
||||
p.CreatedAt,
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
if (data == null)
|
||||
return Error(GlobalMessages.RetirementDeceasedNotFound, 404);
|
||||
var _data = new
|
||||
{
|
||||
data.Id,
|
||||
data.Prefix,
|
||||
data.PrefixId,
|
||||
data.FirstName,
|
||||
data.LastName,
|
||||
data.PositionExecutive,
|
||||
data.PositionType,
|
||||
data.PositionLine,
|
||||
data.PositionLevel,
|
||||
data.Organization,
|
||||
data.PositionExecutiveId,
|
||||
data.PositionTypeId,
|
||||
data.PositionLineId,
|
||||
data.PositionLevelId,
|
||||
data.OrganizationId,
|
||||
data.Number,
|
||||
data.Date,
|
||||
data.Location,
|
||||
data.Reason,
|
||||
data.FileName,
|
||||
PathName = data.PathName == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.PathName),
|
||||
data.IsActive,
|
||||
data.CreatedAt,
|
||||
};
|
||||
|
||||
return Success(_data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// สร้าง รายละเอียดบันทึกเวียนแจ้งการถึงแก่กรรม
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost()]
|
||||
public async Task<ActionResult<ResponseObject>> Post([FromForm] RetirementDeceasedRequest req)
|
||||
{
|
||||
var profile = await _context.Profiles
|
||||
.FirstOrDefaultAsync(x => x.Id == req.ProfileId);
|
||||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
var retirementDeceased = new RetirementDeceased
|
||||
{
|
||||
Profile = profile,
|
||||
Number = req.Number,
|
||||
Date = req.Date,
|
||||
Location = req.Location,
|
||||
Reason = req.Reason,
|
||||
IsActive = true,
|
||||
CreatedUserId = FullName ?? "",
|
||||
CreatedFullName = UserId ?? "System Administrator",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
await _context.RetirementDeceaseds.AddAsync(retirementDeceased);
|
||||
await _context.SaveChangesAsync();
|
||||
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
||||
{
|
||||
var file = Request.Form.Files[0];
|
||||
var fileExtension = Path.GetExtension(file.FileName);
|
||||
|
||||
var doc = await _documentService.UploadFileAsync(file, file.FileName);
|
||||
var _doc = await _context.Documents.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
||||
if (_doc != null)
|
||||
retirementDeceased.Document = _doc;
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// แก้ไข รายละเอียดบันทึกเวียนแจ้งการถึงแก่กรรม
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> Put([FromForm] RetirementDeceasedRequest req, Guid id)
|
||||
{
|
||||
var updated = await _context.RetirementDeceaseds
|
||||
.Include(x => x.Document)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (updated == null)
|
||||
return Error(GlobalMessages.RetirementDeceasedNotFound, 404);
|
||||
|
||||
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
||||
{
|
||||
if (updated.Document != null)
|
||||
await _documentService.DeleteFileAsync(updated.Document.Id);
|
||||
|
||||
var file = Request.Form.Files[0];
|
||||
var fileExtension = Path.GetExtension(file.FileName);
|
||||
|
||||
var doc = await _documentService.UploadFileAsync(file, file.FileName);
|
||||
var _doc = await _context.Documents.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
||||
if (_doc != null)
|
||||
updated.Document = _doc;
|
||||
}
|
||||
updated.Number = req.Number;
|
||||
updated.Date = req.Date;
|
||||
updated.Location = req.Location;
|
||||
updated.Reason = req.Reason;
|
||||
updated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
updated.LastUpdateUserId = UserId ?? "";
|
||||
updated.LastUpdatedAt = DateTime.Now;
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบ รายละเอียดบันทึกเวียนแจ้งการถึงแก่กรรม
|
||||
/// </summary>
|
||||
/// <param name="id">Id การถึงแก่กรรม</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> Delete(Guid id)
|
||||
{
|
||||
var deleted = await _context.RetirementDeceaseds.AsQueryable()
|
||||
.Include(x => x.Document)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (deleted == null)
|
||||
return Error(GlobalMessages.RetirementDeceasedNotFound, 404);
|
||||
if (deleted.Document != null)
|
||||
await _documentService.DeleteFileAsync(deleted.Document.Id);
|
||||
_context.RetirementDeceaseds.Remove(deleted);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,317 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using BMA.EHR.Retirement.Service.Requests;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace BMA.EHR.Retirement.Service.Controllers
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/retirement/resign")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
[Authorize]
|
||||
[SwaggerTag("ระบบลาออก")]
|
||||
public class RetirementResignController : BaseController
|
||||
{
|
||||
private readonly RetirementRepository _repository;
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public RetirementResignController(RetirementRepository repository,
|
||||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_repository = repository;
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
||||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// list รายการลาออกของ User
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("user")]
|
||||
public async Task<ActionResult<ResponseObject>> GetListByProfile()
|
||||
{
|
||||
var profile = await _context.Profiles
|
||||
.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId));
|
||||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
var retirementResigns = await _context.RetirementResigns.AsQueryable()
|
||||
.Where(x => x.Profile == profile)
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.Location,
|
||||
p.SendDate,
|
||||
p.ActiveDate,
|
||||
p.Reason,
|
||||
p.Status,
|
||||
p.IsActive,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
return Success(retirementResigns);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// list รายการลาออกของ Admin
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet()]
|
||||
public async Task<ActionResult<ResponseObject>> GetListByAdmin()
|
||||
{
|
||||
|
||||
var retirementResigns = await _context.RetirementResigns.AsQueryable()
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||
p.Profile.FirstName,
|
||||
p.Profile.LastName,
|
||||
p.Location,
|
||||
p.SendDate,
|
||||
p.ActiveDate,
|
||||
p.Reason,
|
||||
p.Status,
|
||||
PositionType = p.PositionType == null ? null : p.PositionType.Name,
|
||||
PositionLine = p.PositionLine == null ? null : p.PositionLine.Name,
|
||||
PositionLevel = p.PositionLevel == null ? null : p.PositionLevel.Name,
|
||||
PositionExecutive = p.PositionExecutive == null ? null : p.PositionExecutive.Name,
|
||||
OrganizationOrganization = p.OrganizationOrganization == null ? null : p.OrganizationOrganization.Name,
|
||||
p.IsActive,
|
||||
p.CreatedAt,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
return Success(retirementResigns);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get รายละเอียดลาออก
|
||||
/// </summary>
|
||||
/// <param name="id">Id ลาออก</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetDetailByUser(Guid id)
|
||||
{
|
||||
var data = await _context.RetirementResigns.AsQueryable()
|
||||
.Where(x => x.Id == id)
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
|
||||
p.Profile.FirstName,
|
||||
p.Profile.LastName,
|
||||
p.Location,
|
||||
p.SendDate,
|
||||
p.ActiveDate,
|
||||
p.Reason,
|
||||
p.Status,
|
||||
PositionType = p.PositionType == null ? null : p.PositionType.Name,
|
||||
PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
|
||||
PositionLine = p.PositionLine == null ? null : p.PositionLine.Name,
|
||||
PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
|
||||
PositionLevel = p.PositionLevel == null ? null : p.PositionLevel.Name,
|
||||
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
|
||||
PositionExecutive = p.PositionExecutive == null ? null : p.PositionExecutive.Name,
|
||||
PositionExecutiveId = p.PositionExecutive == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionExecutive.Id,
|
||||
OrganizationOrganization = p.OrganizationOrganization == null ? null : p.OrganizationOrganization.Name,
|
||||
OrganizationOrganizationId = p.OrganizationOrganization == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationOrganization.Id,
|
||||
p.IsActive,
|
||||
p.CreatedAt,
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
if (data == null)
|
||||
return Error(GlobalMessages.RetirementResignNotFound, 404);
|
||||
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// สร้างการลาออก
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost()]
|
||||
public async Task<ActionResult<ResponseObject>> Post([FromForm] RetirementResignRequest req)
|
||||
{
|
||||
var profile = await _context.Profiles
|
||||
.Include(x => x.PositionType)
|
||||
.Include(x => x.PositionLevel)
|
||||
.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId));
|
||||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
var retirementResign = new RetirementResign
|
||||
{
|
||||
Profile = profile,
|
||||
Location = req.Location,
|
||||
SendDate = req.SendDate,
|
||||
ActiveDate = req.ActiveDate,
|
||||
Reason = req.Reason,
|
||||
PositionType = profile.PositionType,
|
||||
PositionLine = await _context.PositionLines
|
||||
.FirstOrDefaultAsync(x => x.Id == profile.PositionLineId),
|
||||
PositionLevel = profile.PositionLevel,
|
||||
PositionExecutive = await _context.PositionExecutives
|
||||
.FirstOrDefaultAsync(x => x.Id == profile.PositionExecutiveId),
|
||||
OrganizationOrganization = await _context.OrganizationOrganizations
|
||||
.FirstOrDefaultAsync(x => x.Id == profile.OrganizationOrganizationId),
|
||||
Status = "PENDING",
|
||||
IsActive = true,
|
||||
CreatedUserId = FullName ?? "",
|
||||
CreatedFullName = UserId ?? "System Administrator",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
await _context.RetirementResigns.AddAsync(retirementResign);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// แก้ไขการลาออก
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> Put([FromForm] RetirementResignRequest req, Guid id)
|
||||
{
|
||||
var updated = await _context.RetirementResigns
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (updated == null)
|
||||
return Error(GlobalMessages.RetirementResignNotFound, 404);
|
||||
|
||||
updated.Location = req.Location;
|
||||
updated.SendDate = req.SendDate;
|
||||
updated.ActiveDate = req.ActiveDate;
|
||||
updated.Reason = req.Reason;
|
||||
updated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
updated.LastUpdateUserId = UserId ?? "";
|
||||
updated.LastUpdatedAt = DateTime.Now;
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบลาออก
|
||||
/// </summary>
|
||||
/// <param name="id">Id ลาออก</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> Delete(Guid id)
|
||||
{
|
||||
var deleted = await _context.RetirementResigns.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (deleted == null)
|
||||
return Error(GlobalMessages.RetirementResignNotFound, 404);
|
||||
_context.RetirementResigns.Remove(deleted);
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// อนุมัติคำลาออก
|
||||
/// </summary>
|
||||
/// <param name="id">Id คำลาออก</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("confirm/{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> AdminConfirm(Guid id)
|
||||
{
|
||||
var updated = await _context.RetirementResigns
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (updated == null)
|
||||
return Error(GlobalMessages.RetirementResignNotFound, 404);
|
||||
|
||||
updated.Status = "APPROVE";
|
||||
updated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
updated.LastUpdateUserId = UserId ?? "";
|
||||
updated.LastUpdatedAt = DateTime.Now;
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ไม่อนุมัติคำลาออก
|
||||
/// </summary>
|
||||
/// <param name="id">Id คำลาออก</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("reject/{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> AdminReject(Guid id)
|
||||
{
|
||||
var updated = await _context.RetirementResigns
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (updated == null)
|
||||
return Error(GlobalMessages.RetirementResignNotFound, 404);
|
||||
|
||||
updated.Status = "REJECT";
|
||||
updated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
updated.LastUpdateUserId = UserId ?? "";
|
||||
updated.LastUpdatedAt = DateTime.Now;
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Retirement.Service.Requests
|
||||
{
|
||||
public class RetirementDeceasedRequest
|
||||
{
|
||||
public FormFile? File { get; set; }
|
||||
public string? Number { get; set; }
|
||||
public DateTime? Date { get; set; }
|
||||
public string? Location { get; set; }
|
||||
public string? Reason { get; set; }
|
||||
public Guid ProfileId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Retirement.Service.Requests
|
||||
{
|
||||
public class RetirementResignRequest
|
||||
{
|
||||
public string? Location { get; set; }
|
||||
public DateTime? SendDate { get; set; }
|
||||
public DateTime? ActiveDate { get; set; }
|
||||
public string? Reason { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue