Merge branch 'develop' into work

This commit is contained in:
Kittapath 2023-08-03 09:36:36 +07:00
commit 1e405e8958
35 changed files with 73678 additions and 57 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,109 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddCommandDeployandReceiver : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CommandDeployments",
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"),
CommandId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "รหัสอ้างอิงคำสั่ง", collation: "ascii_general_ci"),
ReceiveUserId = table.Column<string>(type: "longtext", nullable: false, comment: "รหัสอ้างอิงผู้ใช้งานระบบ")
.Annotation("MySql:CharSet", "utf8mb4"),
IsSendMail = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "ส่งอีเมล์หรือไม่?"),
IsSendInbox = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "ส่งกล่องข้อความหรือไม่?"),
IsSendNotification = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "ส่งแจ้งเตือนหรือไม่?")
},
constraints: table =>
{
table.PrimaryKey("PK_CommandDeployments", x => x.Id);
table.ForeignKey(
name: "FK_CommandDeployments_Commands_CommandId",
column: x => x.CommandId,
principalTable: "Commands",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "CommandReceivers",
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"),
CommandId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "รหัสอ้างอิงคำสั่ง", collation: "ascii_general_ci"),
Sequence = table.Column<int>(type: "int", nullable: false, comment: "ลำดับในบัญชีแนบท้าย"),
CitizenId = table.Column<string>(type: "varchar(13)", maxLength: 13, nullable: false, comment: "เลขประจำตัวประชาชน")
.Annotation("MySql:CharSet", "utf8mb4"),
Prefix = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "คำนำหน้านาม")
.Annotation("MySql:CharSet", "utf8mb4"),
FirstName = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false, comment: "ชื่อ")
.Annotation("MySql:CharSet", "utf8mb4"),
LastName = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false, comment: "นามสกุล")
.Annotation("MySql:CharSet", "utf8mb4"),
Comment = table.Column<string>(type: "text", nullable: false, comment: "หมายเหตุ")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_CommandReceivers", x => x.Id);
table.ForeignKey(
name: "FK_CommandReceivers_Commands_CommandId",
column: x => x.CommandId,
principalTable: "Commands",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_CommandDeployments_CommandId",
table: "CommandDeployments",
column: "CommandId");
migrationBuilder.CreateIndex(
name: "IX_CommandReceivers_CommandId",
table: "CommandReceivers",
column: "CommandId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CommandDeployments");
migrationBuilder.DropTable(
name: "CommandReceivers");
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,32 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddOwnerGovIdtoCommandTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "OwnerGovId",
table: "Commands",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
comment: "รหัสส่วนราชการผู้ออกคำสั่ง",
collation: "ascii_general_ci");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "OwnerGovId",
table: "Commands");
}
}
}

View file

@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddCommandCodetoCommandTypeTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "CommandCode",
table: "CommandTypes",
type: "longtext",
nullable: false,
comment: "รหัสของประเภทคำสั่ง")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CommandCode",
table: "CommandTypes");
}
}
}

View file

@ -0,0 +1,31 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddRefToPlacementProfiletoCommandReceiverTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "RefPlacementProfileId",
table: "CommandReceivers",
type: "char(36)",
nullable: true,
comment: "รหัสอ้างอิงไปยังข้อมูลผู้บรรจุ",
collation: "ascii_general_ci");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "RefPlacementProfileId",
table: "CommandReceivers");
}
}
}

View file

@ -0,0 +1,129 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddFieldtoCommandDeploymentTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "ExamRoundId",
table: "Commands",
newName: "PlacementId");
migrationBuilder.AddColumn<string>(
name: "CitizenId",
table: "CommandDeployments",
type: "varchar(13)",
maxLength: 13,
nullable: false,
defaultValue: "",
comment: "เลขประจำตัวประชาชน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "FirstName",
table: "CommandDeployments",
type: "varchar(100)",
maxLength: 100,
nullable: false,
defaultValue: "",
comment: "ชื่อ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "LastName",
table: "CommandDeployments",
type: "varchar(100)",
maxLength: 100,
nullable: false,
defaultValue: "",
comment: "นามสกุล")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "OrganizationName",
table: "CommandDeployments",
type: "longtext",
nullable: false,
comment: "ชื่อหน่วยงานของผู้รับสำเนาคำสั่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "Prefix",
table: "CommandDeployments",
type: "varchar(50)",
maxLength: 50,
nullable: false,
defaultValue: "",
comment: "คำนำหน้านาม")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<int>(
name: "Sequence",
table: "CommandDeployments",
type: "int",
nullable: false,
defaultValue: 0,
comment: "ลำดับ");
migrationBuilder.CreateIndex(
name: "IX_Commands_PlacementId",
table: "Commands",
column: "PlacementId");
migrationBuilder.AddForeignKey(
name: "FK_Commands_Placements_PlacementId",
table: "Commands",
column: "PlacementId",
principalTable: "Placements",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Commands_Placements_PlacementId",
table: "Commands");
migrationBuilder.DropIndex(
name: "IX_Commands_PlacementId",
table: "Commands");
migrationBuilder.DropColumn(
name: "CitizenId",
table: "CommandDeployments");
migrationBuilder.DropColumn(
name: "FirstName",
table: "CommandDeployments");
migrationBuilder.DropColumn(
name: "LastName",
table: "CommandDeployments");
migrationBuilder.DropColumn(
name: "OrganizationName",
table: "CommandDeployments");
migrationBuilder.DropColumn(
name: "Prefix",
table: "CommandDeployments");
migrationBuilder.DropColumn(
name: "Sequence",
table: "CommandDeployments");
migrationBuilder.RenameColumn(
name: "PlacementId",
table: "Commands",
newName: "ExamRoundId");
}
}
}

View file

@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddPositionNametoCommandDeploymentTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "PositionName",
table: "CommandDeployments",
type: "longtext",
nullable: false,
comment: "ชื่อตำแหน่งของผู้รับสำเนาคำสั่ง")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "PositionName",
table: "CommandDeployments");
}
}
}

View file

@ -113,10 +113,6 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<Guid>("ExamRoundId")
.HasColumnType("char(36)")
.HasComment("อ้างอิงรอบการสอบ");
b.Property<Guid>("IssuerOrganizationId")
.HasColumnType("char(36)")
.HasComment("รหัสอ้างอิงหน่วยงานที่ออกคำสั่ง");
@ -145,6 +141,14 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<Guid>("OwnerGovId")
.HasColumnType("char(36)")
.HasComment("รหัสส่วนราชการผู้ออกคำสั่ง");
b.Property<Guid>("PlacementId")
.HasColumnType("char(36)")
.HasComment("อ้างอิงรอบการสอบ");
b.Property<string>("PositionName")
.IsRequired()
.HasColumnType("longtext")
@ -156,9 +160,124 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasIndex("CommandTypeId");
b.HasIndex("PlacementId");
b.ToTable("Commands");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandDeployment", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("CitizenId")
.IsRequired()
.HasMaxLength(13)
.HasColumnType("varchar(13)")
.HasComment("เลขประจำตัวประชาชน");
b.Property<Guid>("CommandId")
.HasColumnType("char(36)")
.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<string>("FirstName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)")
.HasComment("ชื่อ");
b.Property<bool>("IsSendInbox")
.HasColumnType("tinyint(1)")
.HasComment("ส่งกล่องข้อความหรือไม่?");
b.Property<bool>("IsSendMail")
.HasColumnType("tinyint(1)")
.HasComment("ส่งอีเมล์หรือไม่?");
b.Property<bool>("IsSendNotification")
.HasColumnType("tinyint(1)")
.HasComment("ส่งแจ้งเตือนหรือไม่?");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)")
.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>("OrganizationName")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ชื่อหน่วยงานของผู้รับสำเนาคำสั่ง");
b.Property<string>("PositionName")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ชื่อตำแหน่งของผู้รับสำเนาคำสั่ง");
b.Property<string>("Prefix")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasComment("คำนำหน้านาม");
b.Property<string>("ReceiveUserId")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รหัสอ้างอิงผู้ใช้งานระบบ");
b.Property<int>("Sequence")
.HasColumnType("int")
.HasComment("ลำดับ");
b.HasKey("Id");
b.HasIndex("CommandId");
b.ToTable("CommandDeployments");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandDocument", b =>
{
b.Property<Guid>("Id")
@ -226,6 +345,101 @@ namespace BMA.EHR.Infrastructure.Migrations
b.ToTable("CommandDocuments");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandReceiver", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("CitizenId")
.IsRequired()
.HasMaxLength(13)
.HasColumnType("varchar(13)")
.HasComment("เลขประจำตัวประชาชน");
b.Property<Guid>("CommandId")
.HasColumnType("char(36)")
.HasComment("รหัสอ้างอิงคำสั่ง");
b.Property<string>("Comment")
.IsRequired()
.HasColumnType("text")
.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<string>("FirstName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)")
.HasComment("ชื่อ");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)")
.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>("Prefix")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasComment("คำนำหน้านาม");
b.Property<Guid?>("RefPlacementProfileId")
.HasColumnType("char(36)")
.HasComment("รหัสอ้างอิงไปยังข้อมูลผู้บรรจุ");
b.Property<int>("Sequence")
.HasColumnType("int")
.HasComment("ลำดับในบัญชีแนบท้าย");
b.HasKey("Id");
b.HasIndex("CommandId");
b.ToTable("CommandReceivers");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandStatus", b =>
{
b.Property<Guid>("Id")
@ -303,6 +517,11 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("varchar(100)")
.HasComment("ประเภทคำสั่ง");
b.Property<string>("CommandCode")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รหัสของประเภทคำสั่ง");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
@ -10439,9 +10658,28 @@ namespace BMA.EHR.Infrastructure.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BMA.EHR.Domain.Models.Placement.Placement", "Placement")
.WithMany()
.HasForeignKey("PlacementId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CommandStatus");
b.Navigation("CommandType");
b.Navigation("Placement");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandDeployment", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Commands.Core.Command", "Command")
.WithMany("Deployments")
.HasForeignKey("CommandId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Command");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandDocument", b =>
@ -10463,6 +10701,17 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("Document");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.CommandReceiver", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Commands.Core.Command", "Command")
.WithMany("Receivers")
.HasForeignKey("CommandId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Command");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.HR.LimitTypeLeave", b =>
{
b.HasOne("BMA.EHR.Domain.Models.HR.LimitLeave", "LimitLeave")
@ -11599,7 +11848,11 @@ namespace BMA.EHR.Infrastructure.Migrations
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.Command", b =>
{
b.Navigation("Deployments");
b.Navigation("Documents");
b.Navigation("Receivers");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.HR.LimitLeave", b =>

View file

@ -1,17 +1,16 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Domain.Models.Commands.Core;
using BMA.EHR.Domain.Models.Documents;
using BMA.EHR.Domain.Models.HR;
using BMA.EHR.Domain.Models.Insignias;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.OrganizationEmployee;
using BMA.EHR.Domain.Models.Notifications;
using BMA.EHR.Domain.Models.OrganizationEmployee;
using BMA.EHR.Domain.Models.Organizations;
using BMA.EHR.Domain.Models.Organizations.Report2;
using BMA.EHR.Domain.Models.Placement;
using Microsoft.EntityFrameworkCore;
using BMA.EHR.Domain.Models.Commands.Core;
using BMA.EHR.Domain.Models.Commands;
using BMA.EHR.Domain.Models.Insignias;
using BMA.EHR.Domain.Models.Retirement;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Infrastructure.Persistence
{
@ -272,9 +271,12 @@ namespace BMA.EHR.Infrastructure.Persistence
public DbSet<DeploymentChannel> DeploymentChannels { get; set; }
public DbSet<Command> Commands { get; set; }
public DbSet<CommandDeployment> CommandDeployments { get; set; }
public DbSet<CommandReceiver> CommandReceivers { get; set; }
#endregion
#region " Message Queue "

View file

@ -44,5 +44,42 @@ namespace BMA.EHR.Infrastructure.Persistence
}
}
}
public static async Task SeedCommandType(WebApplication app)
{
using var scope = app.Services.CreateScope();
var service = scope.ServiceProvider.GetRequiredService<CommandTypeRepository>();
if ((await service.GetAllAsync()).Count() == 0)
{
// read excels into object
var excelFile = "SeedCommand.xlsx";
using (var excel = new ExcelPackage(new FileInfo(excelFile)))
{
var workSheet = excel.Workbook.Worksheets.FirstOrDefault(x => x.Name.ToLower() == "commandtype");
var totalRows = workSheet?.Dimension.Rows;
int row = 2;
while (row <= totalRows)
{
var cell1 = workSheet?.Cells[row, 1]?.GetValue<string>();
if (cell1 == "" || cell1 == null) break;
var inserted = new CommandType
{
Id = Guid.Parse(workSheet?.Cells[row, 1]?.GetValue<string>()!),
Name = workSheet?.Cells[row, 2]?.GetValue<string>()!,
Category = workSheet?.Cells[row, 3]?.GetValue<string>()!,
CommandCode = workSheet?.Cells[row, 4]?.GetValue<string>()!
};
await service.AddAsync(inserted);
row++;
}
}
}
}
}
}

View file

@ -7,7 +7,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using System.Net.Http.Headers;
using Microsoft.AspNetCore.Hosting;
namespace BMA.EHR.Application.Repositories
{
@ -213,6 +212,7 @@ namespace BMA.EHR.Application.Repositories
}
#endregion
public List<Guid> GetAllIdByRoot(Guid? id)
{
try