อัพโหลดเอกสารสร้างรอบสมัคร
This commit is contained in:
parent
9f115e3c72
commit
c986fc1500
13 changed files with 2278 additions and 315 deletions
|
|
@ -119,7 +119,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
/// <response code="200">เมื่อทำการอ่านข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost]
|
||||
[HttpPost, DisableRequestSizeLimit]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
|
|
@ -127,7 +127,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
await _periodExamService.CreateAsync(item);
|
||||
if (Request.Form.Files == null || Request.Form.Files.Count == 0)
|
||||
{
|
||||
return Error(GlobalMessages.NoFileToUpload);
|
||||
}
|
||||
|
||||
var files = Request.Form.Files;
|
||||
await _periodExamService.CreateAsync(item, files);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -146,7 +152,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
/// <response code="200">เมื่อทำการอ่านข้อมูลรอบการสมัครสอบ และ คนสมัครสอบในรอบสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("{examId:length(36)}")]
|
||||
[HttpPut("{examId:length(36)}"), DisableRequestSizeLimit]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
|
|
@ -154,7 +160,14 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
await _periodExamService.UpdateAsync(examId, item);
|
||||
if (Request.Form.Files == null || Request.Form.Files.Count == 0)
|
||||
{
|
||||
return Error(GlobalMessages.NoFileToUpload);
|
||||
}
|
||||
|
||||
var files = Request.Form.Files;
|
||||
|
||||
await _periodExamService.UpdateAsync(examId, item, files);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Data
|
|||
public DbSet<Document> Documents { get; set; }
|
||||
|
||||
public DbSet<CandidateDocument> CandidateDocuments { get; set; }
|
||||
|
||||
public DbSet<PositionExam> PositionExams { get; set; }
|
||||
|
||||
public DbSet<BankExam> BankExams { get; set; }
|
||||
|
||||
public DbSet<PeriodExamDocument> PeriodExamDocuments { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -972,6 +972,68 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
|
|||
b.ToTable("PeriodExams");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PeriodExamDocument", 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<Guid>("DocumentId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
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<Guid>("PeriodExamId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DocumentId");
|
||||
|
||||
b.HasIndex("PeriodExamId");
|
||||
|
||||
b.ToTable("PeriodExamDocuments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PositionExam", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
|
@ -1553,6 +1615,25 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
|
|||
b.Navigation("EducationLevel");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PeriodExamDocument", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.Documents.Document", "Document")
|
||||
.WithMany()
|
||||
.HasForeignKey("DocumentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", "PeriodExam")
|
||||
.WithMany("PeriodExamDocuments")
|
||||
.HasForeignKey("PeriodExamId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Document");
|
||||
|
||||
b.Navigation("PeriodExam");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BMA.EHR.Recurit.Exam.Service.Models.PositionExam", b =>
|
||||
{
|
||||
b.HasOne("BMA.EHR.Recurit.Exam.Service.Models.PeriodExam", "PeriodExam")
|
||||
|
|
@ -1584,6 +1665,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
|
|||
|
||||
b.Navigation("Candidate");
|
||||
|
||||
b.Navigation("PeriodExamDocuments");
|
||||
|
||||
b.Navigation("PositionExam");
|
||||
});
|
||||
|
||||
|
|
|
|||
1683
Migrations/20230407034739_Update table exam add document.Designer.cs
generated
Normal file
1683
Migrations/20230407034739_Update table exam add document.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
68
Migrations/20230407034739_Update table exam add document.cs
Normal file
68
Migrations/20230407034739_Update table exam add document.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Updatetableexamadddocument : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PeriodExamDocuments",
|
||||
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"),
|
||||
PeriodExamId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
DocumentId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PeriodExamDocuments", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PeriodExamDocuments_Documents_DocumentId",
|
||||
column: x => x.DocumentId,
|
||||
principalTable: "Documents",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PeriodExamDocuments_PeriodExams_PeriodExamId",
|
||||
column: x => x.PeriodExamId,
|
||||
principalTable: "PeriodExams",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PeriodExamDocuments_DocumentId",
|
||||
table: "PeriodExamDocuments",
|
||||
column: "DocumentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PeriodExamDocuments_PeriodExamId",
|
||||
table: "PeriodExamDocuments",
|
||||
column: "PeriodExamId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "PeriodExamDocuments");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -77,5 +77,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Models
|
|||
|
||||
[Comment("ช่องทางชำระเงิน")]
|
||||
public List<BankExam> BankExam { get; set; } = new List<BankExam>();
|
||||
|
||||
[Comment("เอกสารอื่นๆ")]
|
||||
public virtual List<PeriodExamDocument> PeriodExamDocuments { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
15
Models/PeriodExamDocument.cs
Normal file
15
Models/PeriodExamDocument.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using BMA.EHR.Recurit.Exam.Service.Models.Documents;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Models
|
||||
{
|
||||
public class PeriodExamDocument : EntityBase
|
||||
{
|
||||
[Required, Comment("Id รอบสมัครสอบ")]
|
||||
public virtual PeriodExam? PeriodExam { get; set; }
|
||||
[Required, Comment("Id ไฟล์เอกสาร")]
|
||||
public virtual Document? Document { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Request
|
|||
public bool Consend { get; set; }
|
||||
public bool Position { get; set; }
|
||||
public bool Bank { get; set; }
|
||||
public bool Payment { get; set; }
|
||||
public string? Status { get; set; }
|
||||
public PositionExam? PositionExam { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@
|
|||
{
|
||||
public string? Id { get; set; }
|
||||
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string? FileName { get; set; } = string.Empty;
|
||||
|
||||
public string FileType { get; set; } = string.Empty;
|
||||
public string? FileType { get; set; } = string.Empty;
|
||||
|
||||
public int FileSize { get; set; }
|
||||
public int? FileSize { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
35
Response/PeriodExamCandidateResponseItem.cs
Normal file
35
Response/PeriodExamCandidateResponseItem.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
using BMA.EHR.Recurit.Exam.Service.Responses.Document;
|
||||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Response
|
||||
{
|
||||
public class PeriodExamCandidateResponseItem
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public bool CheckDocument { get; set; }
|
||||
public bool CheckDisability { get; set; }
|
||||
public int? Round { get; set; }
|
||||
public int? Year { get; set; }
|
||||
public float? Fee { get; set; }
|
||||
public DateTime RegisterStartDate { get; set; }
|
||||
public DateTime RegisterEndDate { get; set; }
|
||||
public DateTime PaymentStartDate { get; set; }
|
||||
public DateTime PaymentEndDate { get; set; }
|
||||
public DateTime AnnouncementStartDate { get; set; }
|
||||
public DateTime AnnouncementEndDate { get; set; }
|
||||
public Guid? OrganizationCodeId { get; set; }
|
||||
public string? OrganizationCodeName { get; set; }
|
||||
public Guid? OrganizationId { get; set; }
|
||||
public string? OrganizationName { get; set; }
|
||||
public string? PaymentKrungThai { get; set; }
|
||||
public string? Detail { get; set; }
|
||||
public string? Note { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
public bool SetSeat { get; set; }
|
||||
public List<Models.Candidate> Candidate { get; set; } = new List<Models.Candidate>();
|
||||
public List<Models.PositionExam> PositionExam { get; set; } = new List<Models.PositionExam>();
|
||||
public List<Models.BankExam> BankExam { get; set; } = new List<Models.BankExam>();
|
||||
public List<FileListResponse> Documents { get; set; } = new List<FileListResponse>();
|
||||
}
|
||||
}
|
||||
|
|
@ -542,6 +542,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
Status = candidate == null ? null : candidate.Status,
|
||||
PositionExam = candidatePosition?.PositionExam,
|
||||
Bank = exam.BankExam.Count() > 0,
|
||||
Payment = exam.Fee > 0,
|
||||
Position = candidatePosition == null ? false : true
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ using System.Text.Json;
|
|||
using BMA.EHR.Recurit.Exam.Service.Core;
|
||||
using BMA.EHR.Recurit.Exam.Service.Data;
|
||||
using BMA.EHR.Recurit.Exam.Service.Models;
|
||||
using BMA.EHR.Recurit.Exam.Service.Models.Documents;
|
||||
using BMA.EHR.Recurit.Exam.Service.Request;
|
||||
using BMA.EHR.Recurit.Exam.Service.Response;
|
||||
using BMA.EHR.Recurit.Exam.Service.Responses.Document;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OfficeOpenXml;
|
||||
|
|
@ -17,16 +19,19 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly MinIOService _minioService;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public PeriodExamService(ApplicationDbContext context,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
MinIOService minioService)
|
||||
{
|
||||
_context = context;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_minioService = minioService;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -41,61 +46,61 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
|
||||
#region " Methods "
|
||||
|
||||
public async Task<IEnumerable<PeriodExam>> GetsAsync(bool showAll = true)
|
||||
public async Task<IEnumerable<PeriodExamCandidateResponseItem>> GetsAsync(bool showAll = true)
|
||||
{
|
||||
if (showAll)
|
||||
return await _context.PeriodExams.AsQueryable()
|
||||
.Include(x => x.PositionExam)
|
||||
.Include(x => x.BankExam)
|
||||
.OrderBy(d => d.Name)
|
||||
.ToListAsync();
|
||||
else
|
||||
return await _context.PeriodExams.AsQueryable()
|
||||
.Include(x => x.PositionExam)
|
||||
.Include(x => x.BankExam)
|
||||
.Where(p => p.IsActive)
|
||||
.OrderBy(d => d.Name)
|
||||
.Select(x => new PeriodExam
|
||||
return await _context.PeriodExams.AsQueryable()
|
||||
.Include(x => x.PositionExam)
|
||||
.Include(x => x.BankExam)
|
||||
.Where(p => p.IsActive)
|
||||
.OrderBy(d => d.Name)
|
||||
.Select(x => new PeriodExamCandidateResponseItem
|
||||
{
|
||||
AnnouncementEndDate = x.AnnouncementEndDate,
|
||||
AnnouncementStartDate = x.AnnouncementStartDate,
|
||||
CheckDisability = x.CheckDisability,
|
||||
CheckDocument = x.CheckDocument,
|
||||
Detail = x.Detail,
|
||||
Fee = x.Fee,
|
||||
Id = x.Id,
|
||||
IsActive = x.IsActive,
|
||||
Name = x.Name,
|
||||
Note = x.Note,
|
||||
OrganizationCodeId = x.OrganizationCodeId,
|
||||
OrganizationCodeName = x.OrganizationCodeName,
|
||||
OrganizationId = x.OrganizationId,
|
||||
OrganizationName = x.OrganizationName,
|
||||
PaymentEndDate = x.PaymentEndDate,
|
||||
PaymentKrungThai = x.PaymentKrungThai,
|
||||
PaymentStartDate = x.PaymentStartDate,
|
||||
RegisterEndDate = x.RegisterEndDate,
|
||||
RegisterStartDate = x.RegisterStartDate,
|
||||
Round = x.Round,
|
||||
SetSeat = x.SetSeat,
|
||||
Year = x.Year,
|
||||
BankExam = x.BankExam.OrderBy(o => o.CreatedAt).Select(b => new BankExam
|
||||
{
|
||||
AnnouncementEndDate = x.AnnouncementEndDate,
|
||||
AnnouncementStartDate = x.AnnouncementStartDate,
|
||||
CheckDisability = x.CheckDisability,
|
||||
CheckDocument = x.CheckDocument,
|
||||
Detail = x.Detail,
|
||||
Fee = x.Fee,
|
||||
Id = x.Id,
|
||||
IsActive = x.IsActive,
|
||||
Name = x.Name,
|
||||
Note = x.Note,
|
||||
OrganizationCodeId = x.OrganizationCodeId,
|
||||
OrganizationCodeName = x.OrganizationCodeName,
|
||||
OrganizationId = x.OrganizationId,
|
||||
OrganizationName = x.OrganizationName,
|
||||
PaymentEndDate = x.PaymentEndDate,
|
||||
PaymentKrungThai = x.PaymentKrungThai,
|
||||
PaymentStartDate = x.PaymentStartDate,
|
||||
RegisterEndDate = x.RegisterEndDate,
|
||||
RegisterStartDate = x.RegisterStartDate,
|
||||
Round = x.Round,
|
||||
SetSeat = x.SetSeat,
|
||||
Year = x.Year,
|
||||
BankExam = x.BankExam.OrderBy(o => o.CreatedAt).Select(b => new BankExam
|
||||
{
|
||||
Id = b.Id,
|
||||
AccountName = b.AccountName,
|
||||
AccountNumber = b.AccountNumber,
|
||||
BankName = b.BankName,
|
||||
}).ToList(),
|
||||
PositionExam = x.PositionExam.OrderBy(o => o.CreatedAt).Select(b => new PositionExam
|
||||
{
|
||||
Id = b.Id,
|
||||
TypeId = b.TypeId,
|
||||
TypeName = b.TypeName,
|
||||
PositionId = b.PositionId,
|
||||
PositionName = b.PositionName,
|
||||
}).ToList(),
|
||||
})
|
||||
.ToListAsync();
|
||||
Id = b.Id,
|
||||
AccountName = b.AccountName,
|
||||
AccountNumber = b.AccountNumber,
|
||||
BankName = b.BankName,
|
||||
}).ToList(),
|
||||
PositionExam = x.PositionExam.OrderBy(o => o.CreatedAt).Select(b => new PositionExam
|
||||
{
|
||||
Id = b.Id,
|
||||
TypeId = b.TypeId,
|
||||
TypeName = b.TypeName,
|
||||
PositionId = b.PositionId,
|
||||
PositionName = b.PositionName,
|
||||
}).ToList(),
|
||||
Documents = x.PeriodExamDocuments.OrderBy(o => o.CreatedAt).Select(b => new FileListResponse
|
||||
{
|
||||
Id = b.Document == null ? "" : b.Document.Id.ToString(),
|
||||
FileName = b.Document == null ? "" : b.Document.FileName,
|
||||
FileSize = b.Document == null ? 0 : b.Document.FileSize,
|
||||
FileType = b.Document == null ? "" : b.Document.FileType,
|
||||
}).ToList(),
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<PeriodExam?> GetsExamAndCandidateAsync(string examId, bool showAll = true)
|
||||
|
|
@ -152,7 +157,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
}
|
||||
}
|
||||
|
||||
public async Task CreateAsync(RequestPeriodExam inserted)
|
||||
public async Task CreateAsync(RequestPeriodExam inserted, IFormFileCollection files)
|
||||
{
|
||||
var periodExam = new PeriodExam
|
||||
{
|
||||
|
|
@ -220,16 +225,37 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.PositionExams.AddAsync(positionExam);
|
||||
}
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
var doc = await _minioService.UploadFileAsync(file);
|
||||
|
||||
var document = await _context.Documents.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
||||
|
||||
if (document == null)
|
||||
throw new Exception(GlobalMessages.NoFileToUpload);
|
||||
|
||||
var periodExamDocument = new PeriodExamDocument
|
||||
{
|
||||
PeriodExam = periodExam,
|
||||
Document = document,
|
||||
};
|
||||
|
||||
await _context.PeriodExamDocuments.AddAsync(periodExamDocument);
|
||||
}
|
||||
|
||||
await _context.PeriodExams.AddAsync(periodExam);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(string examId, RequestPeriodExam updated)
|
||||
public async Task UpdateAsync(string examId, RequestPeriodExam updated, IFormFileCollection files)
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.Include(x => x.BankExam)
|
||||
.Include(x => x.PositionExam)
|
||||
.Include(x => x.PeriodExamDocuments)
|
||||
.ThenInclude(x => x.Document)
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
if (periodExam == null)
|
||||
|
|
@ -348,9 +374,41 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.PositionExams.AddAsync(positionExam);
|
||||
}
|
||||
|
||||
foreach (var doc in periodExam.PeriodExamDocuments)
|
||||
{
|
||||
if (doc.Id != null)
|
||||
{
|
||||
await DeleteAsyncDocument(doc.Id.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
var doc = await _minioService.UploadFileAsync(file);
|
||||
|
||||
var document = await _context.Documents.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
||||
|
||||
if (document == null)
|
||||
throw new Exception(GlobalMessages.NoFileToUpload);
|
||||
|
||||
var periodExamDocument = new PeriodExamDocument
|
||||
{
|
||||
PeriodExam = periodExam,
|
||||
Document = document,
|
||||
};
|
||||
|
||||
await _context.PeriodExamDocuments.AddAsync(periodExamDocument);
|
||||
}
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteAsyncDocument(string documentId)
|
||||
{
|
||||
await _minioService.DeleteFileAsync(Guid.Parse(documentId));
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(string examId)
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue