Merge branch 'develop' into develop-tee

This commit is contained in:
setthawutttty 2023-07-10 17:17:07 +07:00
commit 967d725388
19 changed files with 32182 additions and 154 deletions

View file

@ -239,6 +239,7 @@ namespace BMA.EHR.Domain.Models.HR
// public OrganizationPositionEntity? OrganizationPosition { get; set; }
public LimitLeave? LimitLeave { get; set; }
public Guid? KeycloakId { get; set; }
public virtual List<ProfileEducation> Educations { get; set; } = new List<ProfileEducation>();

View file

@ -1,30 +0,0 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using BMA.EHR.Domain.Models.Base;
namespace BMA.EHR.Domain.Models.Placement
{
public class PlacementCareer : EntityBase
{
[Required, Comment("Id ผู้สมัคร")]
public virtual PlacementProfile? PlacementProfile { get; set; }
[Required, Comment("ระยะเวลาเริ่ม")]
public DateTime DurationStart { get; set; } = DateTime.Now.Date;
[Required, Comment("ระยะเวลาสิ้นสุด")]
public DateTime DurationEnd { get; set; } = DateTime.Now.Date;
[Required, Comment("สถานที่ทำงาน/ฝึกงาน")]
public string Name { get; set; } = string.Empty;
[Required, Comment("ตำแหน่ง/ลักษณะงาน")]
public string Position { get; set; } = string.Empty;
[Required, MaxLength(20), Comment("เงินเดือนสุดท้ายก่อนออก")]
public int Salary { get; set; }
[Required, Comment("เหตุผลที่ออก")]
public string Reason { get; set; } = string.Empty;
}
}

View file

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using BMA.EHR.Domain.Models.Base;
namespace BMA.EHR.Domain.Models.Placement
{
public class PlacementCertificate : EntityBase
{
[Required, Comment("Id ผู้สมัคร")]
public virtual PlacementProfile? PlacementProfile { get; set; }
[MaxLength(20), Comment("เลขที่ใบอนุญาต")]
public string? CertificateNo { get; set; }
[MaxLength(200), Comment("หน่วยงานผู้ออกใบอนุญาต")]
public string? Issuer { get; set; }
[Comment("วันที่ออกใบอนุญาต")]
public DateTime? IssueDate { get; set; }
[Comment("วันที่หมดอายุ")]
public DateTime? ExpireDate { get; set; }
[MaxLength(100), Comment("ชื่อใบอนุญาต")]
public string? CertificateType { get; set; }
}
}

View file

@ -9,23 +9,37 @@ namespace BMA.EHR.Domain.Models.Placement
{
[Required, Comment("Id ผู้สมัคร")]
public virtual PlacementProfile? PlacementProfile { get; set; }
[Comment("Idวุฒิที่ได้รับ")]
public virtual EducationLevel? EducationLevel { get; set; }
[Required, Comment("สาขาวิชา/วิชาเอก")]
public string Major { get; set; } = string.Empty;
[Required, MaxLength(10), Comment("คะแนนเฉลี่ยตลอดหลักสูตร")]
public float Scores { get; set; }
[Required, Comment("ชื่อสถานศึกษา")]
public string Name { get; set; } = string.Empty;
[Required, Comment("ระยะเวลาเริ่ม")]
public DateTime DurationStart { get; set; } = DateTime.Now.Date;
[Required, Comment("ระยะเวลาสิ้นสุด")]
public DateTime DurationEnd { get; set; } = DateTime.Now.Date;
[MaxLength(1000), Comment("สถานศึกษา")]
public string? Institute { get; set; }
[MaxLength(200), Comment("วุฒิการศึกษา")]
public string? Degree { get; set; }
[MaxLength(200), Comment("สาขาวิชา/ทาง")]
public string? Field { get; set; }
[MaxLength(20), Comment("เกรดเฉลี่ย")]
public string? Gpa { get; set; }
[MaxLength(1000), Comment("ประเทศ")]
public string? Country { get; set; }
[MaxLength(1000), Comment("ระยะเวลา")]
public string? Duration { get; set; }
[MaxLength(1000), Comment("ข้อมูลการติดต่อ")]
public string? Other { get; set; }
[MaxLength(1000), Comment("ทุน")]
public string? FundName { get; set; }
[Comment("ระยะเวลาหลักสูตร")]
public int DurationYear { get; set; }
[Comment("วันที่สำเร็จการศึกษา")]
public DateTime? FinishDate { get; set; }
[Comment("ประเภทช่วงเวลาการศึกษา")]
public bool? IsDate { get; set; }
[Comment("ตั้งแต่")]
public DateTime? StartDate { get; set; }
[Comment("ถึง")]
public DateTime? EndDate { get; set; }
[Comment("Id เป็นวุฒิการศึกษาในตำแหน่ง")]
public PositionPath? PositionPath { get; set; }
[Comment("เป็นวุฒิศึกษาในตำแหน่ง")]
public bool? IsEducation { get; set; }
}
}

View file

@ -236,7 +236,7 @@ namespace BMA.EHR.Domain.Models.Placement
[Comment("ผลสมัครสอบ")]
public string? Pass { get; set; }
public virtual List<PlacementCareer> PlacementCareers { get; set; } = new List<PlacementCareer>();
public virtual List<PlacementCertificate> PlacementCertificates { get; set; } = new List<PlacementCertificate>();
public virtual List<PlacementEducation> PlacementEducations { get; set; } = new List<PlacementEducation>();
}
}

View file

@ -54,5 +54,10 @@
public static readonly string PositionEmployeePositionSideNotFound = "ไม่พบข้อมูลด้านของตำแหน่ง";
public static readonly string PositionEmployeePositionNotFound = "ไม่พบข้อมูลตำแหน่ง";
#endregion
#region " Placement "
public static readonly string CertificateNotFound = "ไม่พบข้อมูลใบประกอบอาชีพ";
public static readonly string EducationNotFound = "ไม่พบข้อมูลประวัติการศึกษา";
#endregion
}
}

View file

@ -0,0 +1,185 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class UpdatetablePlacementaddcertificate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PlacementCareers");
migrationBuilder.AddColumn<Guid>(
name: "BloodGroupId",
table: "PlacementProfiles",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<string>(
name: "Race",
table: "PlacementProfiles",
type: "varchar(40)",
maxLength: 40,
nullable: true,
comment: "เชื้อชาติ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<Guid>(
name: "ReligionId",
table: "PlacementProfiles",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.CreateTable(
name: "PlacementCertificates",
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"),
PlacementProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CertificateNo = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: true, comment: "เลขที่ใบอนุญาต")
.Annotation("MySql:CharSet", "utf8mb4"),
Issuer = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true, comment: "หน่วยงานผู้ออกใบอนุญาต")
.Annotation("MySql:CharSet", "utf8mb4"),
IssueDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่ออกใบอนุญาต"),
ExpireDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่หมดอายุ"),
CertificateType = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true, comment: "ชื่อใบอนุญาต")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_PlacementCertificates", x => x.Id);
table.ForeignKey(
name: "FK_PlacementCertificates_PlacementProfiles_PlacementProfileId",
column: x => x.PlacementProfileId,
principalTable: "PlacementProfiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_PlacementProfiles_BloodGroupId",
table: "PlacementProfiles",
column: "BloodGroupId");
migrationBuilder.CreateIndex(
name: "IX_PlacementProfiles_ReligionId",
table: "PlacementProfiles",
column: "ReligionId");
migrationBuilder.CreateIndex(
name: "IX_PlacementCertificates_PlacementProfileId",
table: "PlacementCertificates",
column: "PlacementProfileId");
migrationBuilder.AddForeignKey(
name: "FK_PlacementProfiles_BloodGroups_BloodGroupId",
table: "PlacementProfiles",
column: "BloodGroupId",
principalTable: "BloodGroups",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_PlacementProfiles_Religions_ReligionId",
table: "PlacementProfiles",
column: "ReligionId",
principalTable: "Religions",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_PlacementProfiles_BloodGroups_BloodGroupId",
table: "PlacementProfiles");
migrationBuilder.DropForeignKey(
name: "FK_PlacementProfiles_Religions_ReligionId",
table: "PlacementProfiles");
migrationBuilder.DropTable(
name: "PlacementCertificates");
migrationBuilder.DropIndex(
name: "IX_PlacementProfiles_BloodGroupId",
table: "PlacementProfiles");
migrationBuilder.DropIndex(
name: "IX_PlacementProfiles_ReligionId",
table: "PlacementProfiles");
migrationBuilder.DropColumn(
name: "BloodGroupId",
table: "PlacementProfiles");
migrationBuilder.DropColumn(
name: "Race",
table: "PlacementProfiles");
migrationBuilder.DropColumn(
name: "ReligionId",
table: "PlacementProfiles");
migrationBuilder.CreateTable(
name: "PlacementCareers",
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"),
PlacementProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
DurationEnd = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "ระยะเวลาสิ้นสุด"),
DurationStart = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "ระยะเวลาเริ่ม"),
Name = table.Column<string>(type: "longtext", nullable: false, comment: "สถานที่ทำงาน/ฝึกงาน")
.Annotation("MySql:CharSet", "utf8mb4"),
Position = table.Column<string>(type: "longtext", nullable: false, comment: "ตำแหน่ง/ลักษณะงาน")
.Annotation("MySql:CharSet", "utf8mb4"),
Reason = table.Column<string>(type: "longtext", nullable: false, comment: "เหตุผลที่ออก")
.Annotation("MySql:CharSet", "utf8mb4"),
Salary = table.Column<int>(type: "int", maxLength: 20, nullable: false, comment: "เงินเดือนสุดท้ายก่อนออก")
},
constraints: table =>
{
table.PrimaryKey("PK_PlacementCareers", x => x.Id);
table.ForeignKey(
name: "FK_PlacementCareers_PlacementProfiles_PlacementProfileId",
column: x => x.PlacementProfileId,
principalTable: "PlacementProfiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_PlacementCareers_PlacementProfileId",
table: "PlacementCareers",
column: "PlacementProfileId");
}
}
}

View file

@ -0,0 +1,282 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class UpdatetableplacementEducationaddDegree : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "DurationEnd",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "DurationStart",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "Major",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "Name",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "Scores",
table: "PlacementEducations");
migrationBuilder.AddColumn<string>(
name: "Country",
table: "PlacementEducations",
type: "varchar(1000)",
maxLength: 1000,
nullable: true,
comment: "ประเทศ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "Degree",
table: "PlacementEducations",
type: "varchar(200)",
maxLength: 200,
nullable: true,
comment: "วุฒิการศึกษา")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "Duration",
table: "PlacementEducations",
type: "varchar(1000)",
maxLength: 1000,
nullable: true,
comment: "ระยะเวลา")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<int>(
name: "DurationYear",
table: "PlacementEducations",
type: "int",
nullable: false,
defaultValue: 0,
comment: "ระยะเวลาหลักสูตร");
migrationBuilder.AddColumn<DateTime>(
name: "EndDate",
table: "PlacementEducations",
type: "datetime(6)",
nullable: true,
comment: "ถึง");
migrationBuilder.AddColumn<string>(
name: "Field",
table: "PlacementEducations",
type: "varchar(200)",
maxLength: 200,
nullable: true,
comment: "สาขาวิชา/ทาง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<DateTime>(
name: "FinishDate",
table: "PlacementEducations",
type: "datetime(6)",
nullable: true,
comment: "วันที่สำเร็จการศึกษา");
migrationBuilder.AddColumn<string>(
name: "FundName",
table: "PlacementEducations",
type: "varchar(1000)",
maxLength: 1000,
nullable: true,
comment: "ทุน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "Gpa",
table: "PlacementEducations",
type: "varchar(20)",
maxLength: 20,
nullable: true,
comment: "เกรดเฉลี่ย")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "Institute",
table: "PlacementEducations",
type: "varchar(1000)",
maxLength: 1000,
nullable: true,
comment: "สถานศึกษา")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<bool>(
name: "IsDate",
table: "PlacementEducations",
type: "tinyint(1)",
nullable: true,
comment: "ประเภทช่วงเวลาการศึกษา");
migrationBuilder.AddColumn<bool>(
name: "IsEducation",
table: "PlacementEducations",
type: "tinyint(1)",
nullable: true,
comment: "เป็นวุฒิศึกษาในตำแหน่ง");
migrationBuilder.AddColumn<string>(
name: "Other",
table: "PlacementEducations",
type: "varchar(1000)",
maxLength: 1000,
nullable: true,
comment: "ข้อมูลการติดต่อ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<Guid>(
name: "PositionPathId",
table: "PlacementEducations",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<DateTime>(
name: "StartDate",
table: "PlacementEducations",
type: "datetime(6)",
nullable: true,
comment: "ตั้งแต่");
migrationBuilder.CreateIndex(
name: "IX_PlacementEducations_PositionPathId",
table: "PlacementEducations",
column: "PositionPathId");
migrationBuilder.AddForeignKey(
name: "FK_PlacementEducations_PositionPaths_PositionPathId",
table: "PlacementEducations",
column: "PositionPathId",
principalTable: "PositionPaths",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_PlacementEducations_PositionPaths_PositionPathId",
table: "PlacementEducations");
migrationBuilder.DropIndex(
name: "IX_PlacementEducations_PositionPathId",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "Country",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "Degree",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "Duration",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "DurationYear",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "EndDate",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "Field",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "FinishDate",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "FundName",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "Gpa",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "Institute",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "IsDate",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "IsEducation",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "Other",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "PositionPathId",
table: "PlacementEducations");
migrationBuilder.DropColumn(
name: "StartDate",
table: "PlacementEducations");
migrationBuilder.AddColumn<DateTime>(
name: "DurationEnd",
table: "PlacementEducations",
type: "datetime(6)",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
comment: "ระยะเวลาสิ้นสุด");
migrationBuilder.AddColumn<DateTime>(
name: "DurationStart",
table: "PlacementEducations",
type: "datetime(6)",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
comment: "ระยะเวลาเริ่ม");
migrationBuilder.AddColumn<string>(
name: "Major",
table: "PlacementEducations",
type: "longtext",
nullable: false,
comment: "สาขาวิชา/วิชาเอก")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "Name",
table: "PlacementEducations",
type: "longtext",
nullable: false,
comment: "ชื่อสถานศึกษา")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<float>(
name: "Scores",
table: "PlacementEducations",
type: "float",
maxLength: 10,
nullable: false,
defaultValue: 0f,
comment: "คะแนนเฉลี่ยตลอดหลักสูตร");
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,30 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class UpdatetableprofileaddkeycloakId : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "KeycloakId",
table: "Profiles",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "KeycloakId",
table: "Profiles");
}
}
}

View file

@ -425,6 +425,9 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Property<bool>("IsVerified")
.HasColumnType("tinyint(1)");
b.Property<Guid?>("KeycloakId")
.HasColumnType("char(36)");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
@ -8529,7 +8532,7 @@ namespace BMA.EHR.Infrastructure.Migrations
b.ToTable("Placements");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementCareer", b =>
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementCertificate", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@ -8538,6 +8541,16 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("CertificateNo")
.HasMaxLength(20)
.HasColumnType("varchar(20)")
.HasComment("เลขที่ใบอนุญาต");
b.Property<string>("CertificateType")
.HasMaxLength(100)
.HasColumnType("varchar(100)")
.HasComment("ชื่อใบอนุญาต");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
@ -8557,13 +8570,18 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<DateTime>("DurationEnd")
b.Property<DateTime?>("ExpireDate")
.HasColumnType("datetime(6)")
.HasComment("ระยะเวลาสิ้นสุด");
.HasComment("วันที่หมดอายุ");
b.Property<DateTime>("DurationStart")
b.Property<DateTime?>("IssueDate")
.HasColumnType("datetime(6)")
.HasComment("ระยะเวลาเริ่ม");
.HasComment("วันที่ออกใบอนุญาต");
b.Property<string>("Issuer")
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasComment("หน่วยงานผู้ออกใบอนุญาต");
b.Property<string>("LastUpdateFullName")
.IsRequired()
@ -8584,34 +8602,14 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext")
.HasComment("สถานที่ทำงาน/ฝึกงาน");
b.Property<Guid>("PlacementProfileId")
.HasColumnType("char(36)");
b.Property<string>("Position")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ตำแหน่ง/ลักษณะงาน");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("longtext")
.HasComment("เหตุผลที่ออก");
b.Property<int>("Salary")
.HasMaxLength(20)
.HasColumnType("int")
.HasComment("เงินเดือนสุดท้ายก่อนออก");
b.HasKey("Id");
b.HasIndex("PlacementProfileId");
b.ToTable("PlacementCareers");
b.ToTable("PlacementCertificates");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementEducation", b =>
@ -8623,6 +8621,11 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("Country")
.HasMaxLength(1000)
.HasColumnType("varchar(1000)")
.HasComment("ประเทศ");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
@ -8642,17 +8645,59 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<DateTime>("DurationEnd")
.HasColumnType("datetime(6)")
.HasComment("ระยะเวลาสิ้นสุด");
b.Property<string>("Degree")
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasComment("วุฒิการศึกษา");
b.Property<DateTime>("DurationStart")
.HasColumnType("datetime(6)")
.HasComment("ระยะเวลาเริ่ม");
b.Property<string>("Duration")
.HasMaxLength(1000)
.HasColumnType("varchar(1000)")
.HasComment("ระยะเวลา");
b.Property<int>("DurationYear")
.HasColumnType("int")
.HasComment("ระยะเวลาหลักสูตร");
b.Property<Guid?>("EducationLevelId")
.HasColumnType("char(36)");
b.Property<DateTime?>("EndDate")
.HasColumnType("datetime(6)")
.HasComment("ถึง");
b.Property<string>("Field")
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasComment("สาขาวิชา/ทาง");
b.Property<DateTime?>("FinishDate")
.HasColumnType("datetime(6)")
.HasComment("วันที่สำเร็จการศึกษา");
b.Property<string>("FundName")
.HasMaxLength(1000)
.HasColumnType("varchar(1000)")
.HasComment("ทุน");
b.Property<string>("Gpa")
.HasMaxLength(20)
.HasColumnType("varchar(20)")
.HasComment("เกรดเฉลี่ย");
b.Property<string>("Institute")
.HasMaxLength(1000)
.HasColumnType("varchar(1000)")
.HasComment("สถานศึกษา");
b.Property<bool?>("IsDate")
.HasColumnType("tinyint(1)")
.HasComment("ประเภทช่วงเวลาการศึกษา");
b.Property<bool?>("IsEducation")
.HasColumnType("tinyint(1)")
.HasComment("เป็นวุฒิศึกษาในตำแหน่ง");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
@ -8672,23 +8717,20 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<string>("Major")
.IsRequired()
.HasColumnType("longtext")
.HasComment("สาขาวิชา/วิชาเอก");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ชื่อสถานศึกษา");
b.Property<string>("Other")
.HasMaxLength(1000)
.HasColumnType("varchar(1000)")
.HasComment("ข้อมูลการติดต่อ");
b.Property<Guid>("PlacementProfileId")
.HasColumnType("char(36)");
b.Property<float>("Scores")
.HasMaxLength(10)
.HasColumnType("float")
.HasComment("คะแนนเฉลี่ยตลอดหลักสูตร");
b.Property<Guid?>("PositionPathId")
.HasColumnType("char(36)");
b.Property<DateTime?>("StartDate")
.HasColumnType("datetime(6)")
.HasComment("ตั้งแต่");
b.HasKey("Id");
@ -8696,6 +8738,8 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasIndex("PlacementProfileId");
b.HasIndex("PositionPathId");
b.ToTable("PlacementEducations");
});
@ -8773,6 +8817,9 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("double")
.HasComment("เงินเดือน");
b.Property<Guid?>("BloodGroupId")
.HasColumnType("char(36)");
b.Property<DateTime?>("CitizenDate")
.HasColumnType("datetime(6)")
.HasComment("วันที่ออกบัตร");
@ -9070,6 +9117,11 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Property<Guid?>("PrefixId")
.HasColumnType("char(36)");
b.Property<string>("Race")
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasComment("เชื้อชาติ");
b.Property<DateTime?>("RecruitDate")
.HasColumnType("datetime(6)")
.HasComment("วันที่บรรจุ");
@ -9110,6 +9162,9 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("เหตุผลผ่อนผัน");
b.Property<Guid?>("ReligionId")
.HasColumnType("char(36)");
b.Property<DateTime?>("ReportingDate")
.HasColumnType("datetime(6)")
.HasComment("วันที่รายงานตัว");
@ -9129,6 +9184,8 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasKey("Id");
b.HasIndex("BloodGroupId");
b.HasIndex("CitizenDistrictId");
b.HasIndex("CitizenProvinceId");
@ -9175,6 +9232,8 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasIndex("ReliefDocId");
b.HasIndex("ReligionId");
b.ToTable("PlacementProfiles");
});
@ -9956,10 +10015,10 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("PlacementType");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementCareer", b =>
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementCertificate", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Placement.PlacementProfile", "PlacementProfile")
.WithMany("PlacementCareers")
.WithMany("PlacementCertificates")
.HasForeignKey("PlacementProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -9979,13 +10038,23 @@ namespace BMA.EHR.Infrastructure.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionPath", "PositionPath")
.WithMany()
.HasForeignKey("PositionPathId");
b.Navigation("EducationLevel");
b.Navigation("PlacementProfile");
b.Navigation("PositionPath");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementProfile", b =>
{
b.HasOne("BMA.EHR.Domain.Models.MetaData.BloodGroup", "BloodGroup")
.WithMany()
.HasForeignKey("BloodGroupId");
b.HasOne("BMA.EHR.Domain.Models.MetaData.District", "CitizenDistrict")
.WithMany()
.HasForeignKey("CitizenDistrictId");
@ -10078,6 +10147,12 @@ namespace BMA.EHR.Infrastructure.Migrations
.WithMany()
.HasForeignKey("ReliefDocId");
b.HasOne("BMA.EHR.Domain.Models.MetaData.Religion", "Religion")
.WithMany()
.HasForeignKey("ReligionId");
b.Navigation("BloodGroup");
b.Navigation("CitizenDistrict");
b.Navigation("CitizenProvince");
@ -10123,6 +10198,8 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("Relationship");
b.Navigation("ReliefDoc");
b.Navigation("Religion");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.HR.LimitLeave", b =>
@ -10299,7 +10376,7 @@ namespace BMA.EHR.Infrastructure.Migrations
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementProfile", b =>
{
b.Navigation("PlacementCareers");
b.Navigation("PlacementCertificates");
b.Navigation("PlacementEducations");
});

View file

@ -239,7 +239,7 @@ namespace BMA.EHR.Infrastructure.Persistence
#region " Placements "
public DbSet<Placement> Placements { get; set; }
public DbSet<PlacementCareer> PlacementCareers { get; set; }
public DbSet<PlacementCertificate> PlacementCertificates { get; set; }
public DbSet<PlacementEducation> PlacementEducations { get; set; }
public DbSet<PlacementIsProperty> PlacementIsProperties { get; set; }
public DbSet<PlacementProfile> PlacementProfiles { get; set; }

View file

@ -210,5 +210,47 @@ namespace BMA.EHR.Application.Repositories
}
#endregion
public List<Guid> GetAllIdByRoot(Guid? id)
{
try
{
var ret = new List<Guid>();
if(id == null)
return ret;
var oc = _context.Organizations.FirstOrDefault(x => x.Id == id);
if (oc != null)
ret.Add(oc.Id);
var child = _context.Organizations.AsQueryable().Where(x => x.Parent != null && x.Parent.Id == id).ToList();
if (child.Any())
{
foreach (var item in child)
{
ret.AddRange(GetAllIdByRoot(item.Id));
}
}
return ret;
}
catch
{
throw;
}
}
public async Task<string?> CheckBmaOfficer(string CitizenId)
{
var data = await _context.Profiles.FirstOrDefaultAsync(x => x.CitizenId == CitizenId);
if (data == null)
return null;
if (data.ProfileType.Trim().ToUpper() == "OFFICER")
return "officer";
if (data.EmployeeClass.Trim().ToUpper() == "PERM")
return "employee_perm";
if (data.EmployeeClass.Trim().ToUpper() == "TEMP")
return "employee_temp";
return "employee";
}
}
}

View file

@ -1,19 +1,24 @@
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;
using BMA.EHR.Placement.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.Placement.Service.Controllers
{
[Route("api/[controller]/placement")]
[ApiController]
[Produces("application/json")]
//[Authorize]
[Authorize]
[SwaggerTag("ระบบบรรจุ")]
public class PlacementController : BaseController
{
@ -39,6 +44,8 @@ namespace BMA.EHR.Placement.Service.Controllers
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
#endregion
[HttpGet]
@ -90,23 +97,100 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpGet("pass/{examId:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetExamByPlacement(Guid examId)
{
var data = await _context.PlacementProfiles.Where(x => x.Placement.Id == examId).Select(x => new
if (PlacementAdmin == true)
{
PersonalId = x.Id,
FullName = x.Prefix == null ? null : x.Prefix.Name + $"{x.Firstname} {x.Lastname}",
IdCard = x.CitizenId,
ProfilePhoto = x.Id,
OrganizationName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationOrganization == null ? null : x.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
OrganizationShortName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationShortName == null ? null : x.OrganizationPosition.Organization.OrganizationShortName.Name)),////
PositionNumber = x.PositionNumber == null ? null : x.PositionNumber.Name,
PositionPath = x.PositionPath == null ? null : x.PositionPath.Name,
ReportingDate = x.ReportingDate,
BmaOfficer = x.IsOfficer,
StatusId = x.PlacementStatus,
Disclaim = x.IsRelief,
}).ToListAsync();
var data = await _context.PlacementProfiles.Where(x => x.Placement.Id == examId).Select(x => new
{
PersonalId = x.Id,
FullName = x.Prefix == null ? null : x.Prefix.Name + $"{x.Firstname} {x.Lastname}",
IdCard = x.CitizenId,
ProfilePhoto = x.Id,
OrganizationName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationOrganization == null ? null : x.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
OrganizationShortName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationShortName == null ? null : x.OrganizationPosition.Organization.OrganizationShortName.Name)),////
PositionNumber = x.PositionNumber == null ? null : x.PositionNumber.Name,
PositionPath = x.PositionPath == null ? null : x.PositionPath.Name,
ReportingDate = x.ReportingDate,
BmaOfficer = x.IsOfficer,
StatusId = x.PlacementStatus,
Number = x.Number,
Disclaim = x.IsRelief,
}).ToListAsync();
return Success(data);
var result = new List<dynamic>();
foreach (var p in data)
{
var _data = new
{
p.PersonalId,
p.FullName,
p.IdCard,
p.ProfilePhoto,
p.OrganizationName,
p.OrganizationShortName,
p.PositionNumber,
p.PositionPath,
p.ReportingDate,
BmaOfficer = await _documentService.CheckBmaOfficer(p.IdCard),
p.StatusId,
p.Number,
p.Disclaim,
};
result.Add(_data);
}
return Success(result);
}
else
{
var profileOrg = await _context.Profiles.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId ?? "00000000-0000-0000-0000-000000000000"));
if (profileOrg == null)
return Error(GlobalMessages.DataNotFound, 404);
// var ocIdList = _documentService.GetAllIdByRoot(profileOrg.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : profileOrg.OcId);
var ocIdList = _documentService.GetAllIdByRoot(profileOrg.OcId);
var data = await _context.PlacementProfiles
.Where(x => x.Placement.Id == examId)
.Where(x => x.OrganizationPosition != null)
.Where(x => x.OrganizationPosition.Organization != null)
.Where(x => ocIdList.Contains(x.OrganizationPosition.Organization.Id))
.Select(x => new
{
PersonalId = x.Id,
FullName = x.Prefix == null ? null : x.Prefix.Name + $"{x.Firstname} {x.Lastname}",
IdCard = x.CitizenId,
ProfilePhoto = x.Id,
OrganizationName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationOrganization == null ? null : x.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
OrganizationShortName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationShortName == null ? null : x.OrganizationPosition.Organization.OrganizationShortName.Name)),////
PositionNumber = x.PositionNumber == null ? null : x.PositionNumber.Name,
PositionPath = x.PositionPath == null ? null : x.PositionPath.Name,
ReportingDate = x.ReportingDate,
BmaOfficer = x.IsOfficer,
StatusId = x.PlacementStatus,
Number = x.Number,
Disclaim = x.IsRelief,
}).ToListAsync();
var result = new List<dynamic>();
foreach (var p in data)
{
var _data = new
{
p.PersonalId,
p.FullName,
p.IdCard,
p.ProfilePhoto,
p.OrganizationName,
p.OrganizationShortName,
p.PositionNumber,
p.PositionPath,
p.ReportingDate,
BmaOfficer = await _documentService.CheckBmaOfficer(p.IdCard),
p.StatusId,
p.Number,
p.Disclaim,
};
result.Add(_data);
}
return Success(result);
}
}
[HttpGet("personal/{personalId:length(36)}")]
@ -134,9 +218,24 @@ namespace BMA.EHR.Placement.Service.Controllers
{
PersonalId = x.Id,
IdCard = x.CitizenId,
Prefix = x.Prefix == null ? null : x.Prefix.Name,
PrefixId = x.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.Prefix.Id,
FullName = x.Prefix == null ? null : x.Prefix.Name + $"{x.Firstname} {x.Lastname}",
Firstname = x.Firstname,
Lastname = x.Lastname,
Nationality = x.Nationality,
Race = x.Race,
DateOfBirth = x.DateOfBirth,
Age = x.DateOfBirth == null ? null : x.DateOfBirth.Value.CalculateAgeStrV2(0, 0),
Telephone = x.Telephone,
Gender = x.Gender == null ? null : x.Gender.Name,
GenderId = x.Gender == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.Gender.Id,
Relationship = x.Relationship == null ? null : x.Relationship.Name,
RelationshipId = x.Relationship == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.Relationship.Id,
BloodGroup = x.BloodGroup == null ? null : x.BloodGroup.Name,
BloodGroupId = x.BloodGroup == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.BloodGroup.Id,
Religion = x.Religion == null ? null : x.Religion.Name,
ReligionId = x.Religion == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.Religion.Id,
Address = $"{x.RegistAddress}" +
(x.RegistSubDistrict == null ? null : " แขวง") + (x.RegistSubDistrict == null ? null : x.RegistSubDistrict.Name) +
(x.RegistDistrict == null ? null : " เขต") + (x.RegistDistrict == null ? null : x.RegistDistrict.Name) +
@ -144,12 +243,63 @@ namespace BMA.EHR.Placement.Service.Controllers
(x.RegistSubDistrict == null ? null : " ") + (x.RegistSubDistrict == null ? null : x.RegistSubDistrict.ZipCode),
Education = x.PlacementEducations.Select(p => new
{
Id = p.Id,
EducationLevel = p.EducationLevel == null ? null : p.EducationLevel.Name,
Major = p.Major,
Scores = p.Scores,
Name = p.Name,
DurationStart = p.DurationStart,
DurationEnd = p.DurationEnd,
Institute = p.Institute,
Degree = p.Degree,
Field = p.Field,
Gpa = p.Gpa,
Country = p.Country,
Duration = p.Duration,
Other = p.Other,
FundName = p.FundName,
DurationYear = p.DurationYear,
FinishDate = p.FinishDate,
IsDate = p.IsDate,
StartDate = p.StartDate,
EndDate = p.EndDate,
PositionPath = p.PositionPath == null ? null : p.PositionPath.Name,
IsEducation = p.IsEducation,
}),
RegistSubDistrict = x.RegistSubDistrict == null ? null : x.RegistSubDistrict.Name,
RegistSubDistrictId = x.RegistSubDistrict == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.RegistSubDistrict.Id,
RegistZipCode = x.RegistSubDistrict == null ? null : x.RegistSubDistrict.ZipCode,
RegistDistrict = x.RegistDistrict == null ? null : x.RegistDistrict.Name,
RegistDistrictId = x.RegistDistrict == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.RegistDistrict.Id,
RegistProvince = x.RegistProvince == null ? null : x.RegistProvince.Name,
RegistProvinceId = x.RegistProvince == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.RegistProvince.Id,
CurrentSubDistrict = x.CurrentSubDistrict == null ? null : x.CurrentSubDistrict.Name,
CurrentSubDistrictId = x.CurrentSubDistrict == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.CurrentSubDistrict.Id,
CurrentZipCode = x.CurrentSubDistrict == null ? null : x.CurrentSubDistrict.ZipCode,
CurrentDistrict = x.CurrentDistrict == null ? null : x.CurrentDistrict.Name,
CurrentDistrictId = x.CurrentDistrict == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.CurrentDistrict.Id,
CurrentProvince = x.CurrentProvince == null ? null : x.CurrentProvince.Name,
CurrentProvinceId = x.CurrentProvince == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.CurrentProvince.Id,
RegistSame = x.RegistSame,
MarryPrefix = x.MarryPrefix == null ? null : x.MarryPrefix.Name,
MarryPrefixId = x.MarryPrefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.MarryPrefix.Id,
Couple = x.Marry,
MarryFirstName = x.MarryFirstName,
MarryLastName = x.MarryLastName,
MarryOccupation = x.MarryOccupation,
FatherPrefix = x.FatherPrefix == null ? null : x.FatherPrefix.Name,
FatherPrefixId = x.FatherPrefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.FatherPrefix.Id,
FatherFirstName = x.FatherFirstName,
FatherLastName = x.FatherLastName,
FatherOccupation = x.FatherOccupation,
MotherPrefix = x.MotherPrefix == null ? null : x.MotherPrefix.Name,
MotherPrefixId = x.MotherPrefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.MotherPrefix.Id,
MotherFirstName = x.MotherFirstName,
MotherLastName = x.MotherLastName,
MotherOccupation = x.MotherOccupation,
Certificates = x.PlacementCertificates.Select(p => new
{
Id = p.Id,
CertificateNo = p.CertificateNo,
Issuer = p.Issuer,
IssueDate = p.IssueDate,
ExpireDate = p.ExpireDate,
CertificateType = p.CertificateType,
}),
PointA = x.PointA,
PointB = x.PointB,
@ -211,7 +361,7 @@ namespace BMA.EHR.Placement.Service.Controllers
person.IsRelief = true;
person.ReliefReason = Request.Form.ContainsKey("note") ? Request.Form["note"] : "";
person.PlacementStatus = "UN-CONTAIN";
person.PlacementStatus = "PREPARE-CONTAIN";
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
{
var file = Request.Form.Files[0];
@ -337,6 +487,7 @@ namespace BMA.EHR.Placement.Service.Controllers
person.MouthSalaryAmount = req.MouthSalaryAmount;
person.PositionSalaryAmount = req.PositionSalaryAmount;
person.RecruitDate = req.ContainDate;
person.PlacementStatus = "PREPARE-CONTAIN";
person.LastUpdateFullName = FullName ?? "System Administrator";
person.LastUpdateUserId = UserId ?? "";
person.LastUpdatedAt = DateTime.Now;
@ -345,7 +496,7 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
[HttpGet("information/{personalId:length(36)}")]
[HttpPut("information/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateInformation([FromBody] PersonInformationRequest req, Guid personalId)
{
var person = await _context.PlacementProfiles.FindAsync(personalId);
@ -413,7 +564,7 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
[HttpGet("address/{personalId:length(36)}")]
[HttpPut("address/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateAddress([FromBody] PersonAddressRequest req, Guid personalId)
{
var person = await _context.PlacementProfiles.FindAsync(personalId);
@ -479,7 +630,7 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
[HttpGet("family/{personalId:length(36)}")]
[HttpPut("family/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateFamily([FromBody] PersonFamilyRequest req, Guid personalId)
{
var person = await _context.PlacementProfiles.FindAsync(personalId);
@ -541,35 +692,155 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
[HttpGet("certificate/{personalId:length(36)}")]
[HttpPut("certificate/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateCertificate([FromBody] PersonCertificateRequest req, Guid personalId)
{
var person = await _context.PlacementProfiles.FindAsync(personalId);
var person = await _context.PlacementProfiles
.Include(x => x.PlacementCertificates)
.FirstOrDefaultAsync(x => x.Id == personalId);
if (person == null)
return Error(GlobalMessages.DataNotFound, 404);
person.LastUpdateFullName = FullName ?? "System Administrator";
person.LastUpdateUserId = UserId ?? "";
person.LastUpdatedAt = DateTime.Now;
if (req.Id == null)
{
var data = new PlacementCertificate
{
PlacementProfile = person,
CertificateNo = req.CertificateNo,
Issuer = req.Issuer,
IssueDate = req.IssueDate,
ExpireDate = req.ExpireDate,
CertificateType = req.CertificateType,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.PlacementCertificates.AddAsync(data);
}
else
{
var certificate = person.PlacementCertificates.FirstOrDefault(x => x.Id == req.Id);
if (certificate == null)
return Error(GlobalMessages.CertificateNotFound, 404);
certificate.CertificateNo = req.CertificateNo;
certificate.Issuer = req.Issuer;
certificate.IssueDate = req.IssueDate;
certificate.ExpireDate = req.ExpireDate;
certificate.CertificateType = req.CertificateType;
certificate.LastUpdateFullName = FullName ?? "System Administrator";
certificate.LastUpdateUserId = UserId ?? "";
certificate.LastUpdatedAt = DateTime.Now;
}
_context.SaveChanges();
return Success();
}
[HttpGet("education/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateEducation([FromBody] PersonEducationRequest req, Guid personalId)
[HttpDelete("certificate/{personalId:length(36)}/{certificateId:length(36)}")]
public async Task<ActionResult<ResponseObject>> DeleteCertificate(Guid personalId, Guid certificateId)
{
var person = await _context.PlacementProfiles.FindAsync(personalId);
var person = await _context.PlacementProfiles
.Include(x => x.PlacementCertificates)
.FirstOrDefaultAsync(x => x.Id == personalId);
if (person == null)
return Error(GlobalMessages.DataNotFound, 404);
person.LastUpdateFullName = FullName ?? "System Administrator";
person.LastUpdateUserId = UserId ?? "";
person.LastUpdatedAt = DateTime.Now;
var certificate = person.PlacementCertificates.FirstOrDefault(x => x.Id == certificateId);
if (certificate == null)
return Error(GlobalMessages.CertificateNotFound, 404);
_context.PlacementCertificates.Remove(certificate);
_context.SaveChanges();
return Success();
}
[HttpPut("education/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateEducation([FromBody] PersonEducationRequest req, Guid personalId)
{
// var education = await _context.PlacementEducations
// .Include(x => x.PlacementProfile)
// .FirstOrDefaultAsync(x => x.Id == personalId);
var profile = await _context.PlacementProfiles.FirstOrDefaultAsync(x => x.Id == personalId);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
var educationLevel = await _context.EducationLevels.FirstOrDefaultAsync(x => x.Id == req.EducationLevelId);
if (educationLevel == null && req.EducationLevelId != null)
return Error(GlobalMessages.DataNotFound, 404);
var positionPath = await _context.PositionPaths.FirstOrDefaultAsync(x => x.Id == req.PositionPathId);
if (positionPath == null && req.PositionPathId != null)
return Error(GlobalMessages.DataNotFound, 404);
if (req.Id == null)
{
var data = new PlacementEducation
{
PlacementProfile = profile,
EducationLevel = educationLevel,
PositionPath = positionPath,
Institute = req.Institute,
Degree = req.Degree,
Field = req.Field,
Gpa = req.Gpa,
Country = req.Country,
Duration = req.Duration,
DurationYear = req.DurationYear,
Other = req.Other,
FundName = req.FundName,
FinishDate = req.FinishDate,
StartDate = req.StartDate,
EndDate = req.EndDate,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.PlacementEducations.AddAsync(data);
}
else
{
var education = await _context.PlacementEducations.FirstOrDefaultAsync(x => x.Id == req.Id);
if (education == null)
return Error(GlobalMessages.EducationNotFound, 404);
education.EducationLevel = educationLevel;
education.PositionPath = positionPath;
education.Institute = req.Institute;
education.Degree = req.Degree;
education.Field = req.Field;
education.Gpa = req.Gpa;
education.Country = req.Country;
education.Duration = req.Duration;
education.DurationYear = req.DurationYear;
education.Other = req.Other;
education.FundName = req.FundName;
education.FinishDate = req.FinishDate;
education.StartDate = req.StartDate;
education.EndDate = req.EndDate;
education.LastUpdateFullName = FullName ?? "System Administrator";
education.LastUpdateUserId = UserId ?? "";
education.LastUpdatedAt = DateTime.Now;
}
await _context.SaveChangesAsync();
return Success();
}
[HttpDelete("education/{educationId:length(36)}")]
public async Task<ActionResult<ResponseObject>> DeleteEducation(Guid educationId)
{
var education = await _context.PlacementEducations.FirstOrDefaultAsync(x => x.Id == educationId);
if (education == null)
return Error(GlobalMessages.EducationNotFound, 404);
_context.PlacementEducations.Remove(education);
_context.SaveChanges();
return Success();
}
}
}

View file

@ -5,7 +5,11 @@ namespace BMA.EHR.Placement.Service.Requests
{
public class PersonCertificateRequest
{
public string Name { get; set; }
public bool Value { get; set; }
public Guid? Id { get; set; }
public string? CertificateNo { get; set; }
public string? Issuer { get; set; }
public DateTime? IssueDate { get; set; }
public DateTime? ExpireDate { get; set; }
public string? CertificateType { get; set; }
}
}

View file

@ -5,7 +5,23 @@ namespace BMA.EHR.Placement.Service.Requests
{
public class PersonEducationRequest
{
public string Name { get; set; }
public bool Value { get; set; }
//public string Name { get; set; }
//public bool Value { get; set; }
public Guid? Id { get; set; }
public Guid? EducationLevelId { get; set; }
public Guid? PositionPathId { get; set; }
public string? Institute { get; set; }
public string? Degree { get; set; }
public string? Field { get; set; }
public string? Gpa { get; set; }
public string? Country { get; set; }
public string? Duration { get; set; }
public int DurationYear { get; set; }
public string? Other { get; set; }
public string? FundName { get; set; }
public DateTime? FinishDate { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }
}
}
}

View file

@ -11,31 +11,31 @@ namespace BMA.EHR.Placement.Service.Requests
public string? CoupleLastName { get; set; }
public string? CoupleLastNameOld { get; set; }
public string? CoupleCareer { get; set; }
public string? CoupleCitizenId { get; set; }
public bool CoupleLive { get; set; }
// public string? CoupleCitizenId { get; set; }
// public bool CoupleLive { get; set; }
public Guid? FatherPrefixId { get; set; }
public string? FatherFirstName { get; set; }
public string? FatherLastName { get; set; }
public string? FatherCareer { get; set; }
public string? FatherCitizenId { get; set; }
public bool FatherLive { get; set; }
// public string? FatherCitizenId { get; set; }
// public bool FatherLive { get; set; }
public Guid? MotherPrefixId { get; set; }
public string? MotherFirstName { get; set; }
public string? MotherLastName { get; set; }
public string? MotherCareer { get; set; }
public string? MotherCitizenId { get; set; }
public bool MotherLive { get; set; }
public virtual List<ProfileChildrenRequest> Childrens { get; set; } = new List<ProfileChildrenRequest>();
}
public class ProfileChildrenRequest
{
public Guid? ChildrenPrefixId { get; set; }
public string? ChildrenFirstName { get; set; }
public string? ChildrenLastName { get; set; }
public string? ChildrenCareer { get; set; }
public string? ChildrenCitizenId { get; set; }
public string ChildrenLive { get; set; }
// public string? MotherCitizenId { get; set; }
// public bool MotherLive { get; set; }
// public virtual List<ProfileChildrenRequest> Childrens { get; set; } = new List<ProfileChildrenRequest>();
}
// public class ProfileChildrenRequest
// {
// public Guid? ChildrenPrefixId { get; set; }
// public string? ChildrenFirstName { get; set; }
// public string? ChildrenLastName { get; set; }
// public string? ChildrenCareer { get; set; }
// public string? ChildrenCitizenId { get; set; }
// public string ChildrenLive { get; set; }
// }
}