เพิ่มฟอร์มชำระเงิน

This commit is contained in:
kittapath 2025-01-27 13:11:20 +07:00
parent 47d0f72f30
commit 1cfa4336fd
11 changed files with 3906 additions and 107 deletions

View file

@ -115,6 +115,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
IsActive = x.IsActive,
Name = x.Name,
Note = x.Note,
Remark = x.Remark,
CompanyCode = x.CompanyCode,
CustomerName = x.CustomerName,
Reason = x.Reason,
RefNo1 = x.RefNo1,
OrganizationCodeId = x.OrganizationCodeId,
OrganizationCodeName = x.OrganizationCodeName,
OrganizationId = x.OrganizationId,
@ -160,6 +165,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
IsActive = x.IsActive,
Name = x.Name,
Note = x.Note,
Remark = x.Remark,
CompanyCode = x.CompanyCode,
CustomerName = x.CustomerName,
Reason = x.Reason,
RefNo1 = x.RefNo1,
OrganizationCodeId = x.OrganizationCodeId,
OrganizationCodeName = x.OrganizationCodeName,
OrganizationId = x.OrganizationId,
@ -209,6 +219,22 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
FileType = b.Document == null ? "" : b.Document.FileType,
Detail = b.Document == null ? "" : b.Document.Id.ToString(),
}).ToList(),
BarCodes = x.PeriodExamBarCodes.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,
Detail = b.Document == null ? "" : b.Document.Id.ToString(),
}).ToList(),
QrCodes = x.PeriodExamQrCodes.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,
Detail = b.Document == null ? "" : b.Document.Id.ToString(),
}).ToList(),
})
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
@ -229,6 +255,20 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
periodExam.Documents[i].Detail = _minioService.ImagesPath(Guid.Parse(periodExam.Documents[i].Detail)).Result;
i++;
}
i = 0;
foreach (var item in periodExam.QrCodes)
{
if (periodExam.QrCodes[i].Detail != null && periodExam.QrCodes[i].Detail != "")
periodExam.QrCodes[i].Detail = _minioService.ImagesPath(Guid.Parse(periodExam.QrCodes[i].Detail)).Result;
i++;
}
i = 0;
foreach (var item in periodExam.BarCodes)
{
if (periodExam.BarCodes[i].Detail != null && periodExam.BarCodes[i].Detail != "")
periodExam.BarCodes[i].Detail = _minioService.ImagesPath(Guid.Parse(periodExam.BarCodes[i].Detail)).Result;
i++;
}
return periodExam;
}
@ -319,6 +359,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
EditorCondition = inserted.EditorCondition,
EditorConfirm = inserted.EditorConfirm,
Note = inserted.Note,
Remark = inserted.Remark,
CompanyCode = inserted.CompanyCode,
CustomerName = inserted.CustomerName,
Reason = inserted.Reason,
RefNo1 = inserted.RefNo1,
CreatedAt = DateTime.Now,
CreatedUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
@ -415,6 +460,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
periodExam.EditorCondition = updated.EditorCondition;
periodExam.EditorConfirm = updated.EditorConfirm;
periodExam.Note = updated.Note;
periodExam.Remark = updated.Remark;
periodExam.CompanyCode = updated.CompanyCode;
periodExam.CustomerName = updated.CustomerName;
periodExam.Reason = updated.Reason;
periodExam.RefNo1 = updated.RefNo1;
periodExam.LastUpdatedAt = DateTime.Now;
periodExam.LastUpdateUserId = UserId ?? "";
periodExam.LastUpdateFullName = FullName ?? "";
@ -599,6 +649,73 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
await _context.SaveChangesAsync();
}
public async Task UpdateBarcodeAsync(string examId, IFormFileCollection files)
{
var periodExam = await _context.PeriodExams.AsQueryable()
.Include(x => x.PeriodExamBarCodes)
.ThenInclude(x => x.Document)
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
if (periodExam.PeriodExamBarCodes != null && periodExam.PeriodExamBarCodes[0] != null && periodExam.PeriodExamBarCodes[0].Document != null)
await _minioService.DeleteFileAsync(periodExam.PeriodExamBarCodes[0].Document.Id);
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 periodExamBarCode = new PeriodExamBarCode
{
PeriodExam = periodExam,
Document = document,
};
await _context.PeriodExamBarCodes.AddAsync(periodExamBarCode);
}
await _context.SaveChangesAsync();
}
public async Task UpdateQrcodeAsync(string examId, IFormFileCollection files)
{
var periodExam = await _context.PeriodExams.AsQueryable()
.Include(x => x.PeriodExamBarCodes)
.ThenInclude(x => x.Document)
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
if (periodExam.PeriodExamBarCodes != null && periodExam.PeriodExamBarCodes[0] != null && periodExam.PeriodExamBarCodes[0].Document != null)
await _minioService.DeleteFileAsync(periodExam.PeriodExamBarCodes[0].Document.Id);
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 periodExamQrCode = new PeriodExamQrCode
{
PeriodExam = periodExam,
Document = document,
};
await _context.PeriodExamQrCodes.AddAsync(periodExamQrCode);
}
await _context.SaveChangesAsync();
}
public async Task DeleteDocument(string documentId)
{
await _minioService.DeleteFileAsync(Guid.Parse(documentId));