api ปฏิเสธจ่ายเงิน get ไฟล์สมัครสอบ
This commit is contained in:
parent
9486ad160d
commit
5abeada4a6
32 changed files with 7513 additions and 394 deletions
|
|
@ -49,12 +49,46 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
public async Task<IEnumerable<PeriodExamCandidateResponseItem>> GetsAsync(bool showAll = true)
|
||||
{
|
||||
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
|
||||
{
|
||||
ExamDate = x.ExamDate,
|
||||
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,
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<PeriodExamCandidateResponseItem?> GetsExamAndCandidateAsync(string examId, bool showAll = true)
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.Include(x => x.PositionExam)
|
||||
.Include(x => x.BankExam)
|
||||
.Include(x => x.PeriodExamDocuments)
|
||||
.Select(x => new PeriodExamCandidateResponseItem
|
||||
{
|
||||
ExamDate = x.ExamDate,
|
||||
AnnouncementEndDate = x.AnnouncementEndDate,
|
||||
AnnouncementStartDate = x.AnnouncementStartDate,
|
||||
CheckDisability = x.CheckDisability,
|
||||
|
|
@ -98,19 +132,37 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
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(),
|
||||
Images = x.PeriodExamImages.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(),
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<PeriodExam?> GetsExamAndCandidateAsync(string examId, bool showAll = true)
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
var i = 0;
|
||||
foreach (var item in periodExam.Images)
|
||||
{
|
||||
if (periodExam.Images[i].Detail != null && periodExam.Images[i].Detail != "")
|
||||
periodExam.Images[i].Detail = _minioService.ImagesPath(Guid.Parse(periodExam.Images[i].Detail)).Result;
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
foreach (var item in periodExam.Documents)
|
||||
{
|
||||
if (periodExam.Documents[i].Detail != null && periodExam.Documents[i].Detail != "")
|
||||
periodExam.Documents[i].Detail = _minioService.ImagesPath(Guid.Parse(periodExam.Documents[i].Detail)).Result;
|
||||
i++;
|
||||
}
|
||||
|
||||
return periodExam;
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +209,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
}
|
||||
}
|
||||
|
||||
public async Task CreateAsync(RequestPeriodExam inserted, IFormFileCollection files)
|
||||
public async Task<Guid> CreateAsync(RequestPeriodExam inserted)
|
||||
{
|
||||
var periodExam = new PeriodExam
|
||||
{
|
||||
|
|
@ -172,6 +224,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
PaymentStartDate = inserted.PaymentStartDate,
|
||||
PaymentEndDate = inserted.PaymentEndDate,
|
||||
AnnouncementStartDate = inserted.AnnouncementStartDate,
|
||||
ExamDate = inserted.ExamDate,
|
||||
AnnouncementEndDate = inserted.AnnouncementEndDate,
|
||||
OrganizationCodeId = inserted.OrganizationCodeId,
|
||||
OrganizationCodeName = inserted.OrganizationCodeName,
|
||||
|
|
@ -225,35 +278,18 @@ 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();
|
||||
|
||||
return periodExam.Id;
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(string examId, RequestPeriodExam updated, IFormFileCollection files)
|
||||
public async Task UpdateAsync(string examId, RequestPeriodExam updated)
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.Include(x => x.BankExam)
|
||||
.Include(x => x.PositionExam)
|
||||
.Include(x => x.Candidate)
|
||||
.Include(x => x.PeriodExamDocuments)
|
||||
.ThenInclude(x => x.Document)
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
|
@ -272,6 +308,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
periodExam.PaymentStartDate = updated.PaymentStartDate;
|
||||
periodExam.PaymentEndDate = updated.PaymentEndDate;
|
||||
periodExam.AnnouncementStartDate = updated.AnnouncementStartDate;
|
||||
periodExam.ExamDate = updated.ExamDate;
|
||||
periodExam.AnnouncementEndDate = updated.AnnouncementEndDate;
|
||||
periodExam.OrganizationCodeId = updated.OrganizationCodeId;
|
||||
periodExam.OrganizationCodeName = updated.OrganizationCodeName;
|
||||
|
|
@ -284,20 +321,54 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
periodExam.LastUpdateUserId = UserId ?? "";
|
||||
periodExam.LastUpdateFullName = FullName ?? "";
|
||||
|
||||
foreach (var bank in periodExam.BankExam)
|
||||
if (updated.PaymentKrungThai != "payment2")
|
||||
{
|
||||
var bankData = updated.BankExam
|
||||
.FirstOrDefault(x => x.Id == bank.Id);
|
||||
if (bankData != null)
|
||||
foreach (var bank in periodExam.BankExam)
|
||||
{
|
||||
bank.AccountName = bankData.AccountName;
|
||||
bank.AccountNumber = bankData.AccountNumber;
|
||||
bank.BankName = bankData.BankName;
|
||||
bank.LastUpdatedAt = DateTime.Now;
|
||||
bank.LastUpdateUserId = UserId ?? "";
|
||||
bank.LastUpdateFullName = FullName ?? "";
|
||||
var bankData = updated.BankExam
|
||||
.FirstOrDefault(x => x.Id == bank.Id);
|
||||
if (bankData != null)
|
||||
{
|
||||
bank.AccountName = bankData.AccountName;
|
||||
bank.AccountNumber = bankData.AccountNumber;
|
||||
bank.BankName = bankData.BankName;
|
||||
bank.LastUpdatedAt = DateTime.Now;
|
||||
bank.LastUpdateUserId = UserId ?? "";
|
||||
bank.LastUpdateFullName = FullName ?? "";
|
||||
}
|
||||
else
|
||||
{
|
||||
var bankDelete = await _context.BankExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == bank.Id);
|
||||
|
||||
if (bankDelete != null)
|
||||
_context.BankExams.Remove(bankDelete);
|
||||
}
|
||||
}
|
||||
else
|
||||
var bankAdd = updated.BankExam
|
||||
.Where(x => x.Id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
|
||||
.ToList();
|
||||
foreach (var bank in bankAdd)
|
||||
{
|
||||
var bankExam = new BankExam
|
||||
{
|
||||
PeriodExam = periodExam,
|
||||
AccountName = bank.AccountName,
|
||||
AccountNumber = bank.AccountNumber,
|
||||
BankName = bank.BankName,
|
||||
CreatedAt = DateTime.Now,
|
||||
CreatedUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
CreatedFullName = FullName ?? "",
|
||||
LastUpdateFullName = FullName ?? "",
|
||||
};
|
||||
await _context.BankExams.AddAsync(bankExam);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var bank in periodExam.BankExam)
|
||||
{
|
||||
var bankDelete = await _context.BankExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == bank.Id);
|
||||
|
|
@ -327,31 +398,14 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
.FirstOrDefaultAsync(x => x.Id == position.Id);
|
||||
|
||||
if (positionDelete != null)
|
||||
{
|
||||
if (periodExam.Candidate.Count() > 0)
|
||||
throw new Exception("รอบนี้มีการสมัครแล้วไม่สามารถลบตำแหน่งได้");
|
||||
_context.PositionExams.Remove(positionDelete);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var bankAdd = updated.BankExam
|
||||
.Where(x => x.Id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
|
||||
.ToList();
|
||||
foreach (var bank in bankAdd)
|
||||
{
|
||||
var bankExam = new BankExam
|
||||
{
|
||||
PeriodExam = periodExam,
|
||||
AccountName = bank.AccountName,
|
||||
AccountNumber = bank.AccountNumber,
|
||||
BankName = bank.BankName,
|
||||
CreatedAt = DateTime.Now,
|
||||
CreatedUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
CreatedFullName = FullName ?? "",
|
||||
LastUpdateFullName = FullName ?? "",
|
||||
};
|
||||
await _context.BankExams.AddAsync(bankExam);
|
||||
}
|
||||
|
||||
var positionAdd = updated.PositionExam
|
||||
.Where(x => x.Id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
|
||||
.ToList();
|
||||
|
|
@ -374,13 +428,16 @@ 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());
|
||||
}
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateDocAsync(string examId, IFormFileCollection files)
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
|
|
@ -404,8 +461,50 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteAsyncDocument(string documentId)
|
||||
public async Task UpdateImgAsync(string examId, IFormFileCollection files)
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
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 periodExamImage = new PeriodExamImage
|
||||
{
|
||||
PeriodExam = periodExam,
|
||||
Document = document,
|
||||
};
|
||||
|
||||
await _context.PeriodExamImages.AddAsync(periodExamImage);
|
||||
}
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteDocument(string documentId)
|
||||
{
|
||||
await _minioService.DeleteFileAsync(Guid.Parse(documentId));
|
||||
}
|
||||
|
||||
public async Task DeleteAsyncDocument(string examId, string documentId)
|
||||
{
|
||||
var exam = await _context.PeriodExams.AsQueryable()
|
||||
.Include(x => x.PositionExam)
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
|
||||
if (exam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
await _minioService.DeleteFileAsync(Guid.Parse(documentId));
|
||||
}
|
||||
|
||||
|
|
@ -445,7 +544,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
|
||||
public async Task<CandidateInformationResponseItem?> GetsAsyncInformation(string candidateId)
|
||||
{
|
||||
return await _context.Candidates.AsQueryable()
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.Where(x => x.Id == Guid.Parse(candidateId))
|
||||
.Select(x => new CandidateInformationResponseItem
|
||||
{
|
||||
|
|
@ -467,8 +566,17 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
Telephone = x.Telephone,
|
||||
MobilePhone = x.MobilePhone,
|
||||
Knowledge = x.Knowledge,
|
||||
ProfileImg = x.ProfileImg == null ? "" : x.ProfileImg.Id.ToString(),
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (candidate == null)
|
||||
return candidate;
|
||||
|
||||
if (candidate.ProfileImg != null && candidate.ProfileImg != "")
|
||||
candidate.ProfileImg = _minioService.ImagesPath(Guid.Parse(candidate.ProfileImg)).Result;
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
public async Task<CandidateOccupationResponseItem?> GetsAsyncOccupation(string candidateId)
|
||||
|
|
@ -560,6 +668,37 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<FileListResponse?>> GetsAsyncDocument(string candidateId)
|
||||
{
|
||||
var candidate = await _context.Candidates.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(candidateId));
|
||||
|
||||
if (candidate == null)
|
||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||
|
||||
var document = await _context.CandidateDocuments.AsQueryable()
|
||||
.Where(x => x.Candidate == candidate)
|
||||
.Select(x => new FileListResponse
|
||||
{
|
||||
Id = x.Document == null ? "" : x.Document.Id.ToString(),
|
||||
FileName = x.Document == null ? "" : x.Document.FileName,
|
||||
FileType = x.Document == null ? "" : x.Document.FileType,
|
||||
FileSize = x.Document == null ? 0 : x.Document.FileSize,
|
||||
Detail = x.Document == null ? "" : x.Document.Id.ToString(),
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var i = 0;
|
||||
foreach (var item in document)
|
||||
{
|
||||
if (document[i].Detail != null && document[i].Detail != "")
|
||||
document[i].Detail = _minioService.ImagesPath(Guid.Parse(document[i].Detail)).Result;
|
||||
i++;
|
||||
}
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
private async Task<List<RequestImportSeat>> ReadExcelCandidate(IFormFile formFile)
|
||||
{
|
||||
var list = new List<RequestImportSeat>();
|
||||
|
|
@ -726,16 +865,22 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
return stream;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<BankExam?>> GetsPaymentExamAsync(string examId)
|
||||
public async Task<PeriodExam> GetsPaymentExamAsync(string examId)
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.Include(x => x.BankExam)
|
||||
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
|
||||
.Where(x => x.Id == Guid.Parse(examId))
|
||||
.Select(x => new PeriodExam
|
||||
{
|
||||
BankExam = x.BankExam,
|
||||
Fee = x.Fee,
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (periodExam == null)
|
||||
throw new Exception(GlobalMessages.ExamNotFound);
|
||||
|
||||
return periodExam.BankExam;
|
||||
return periodExam;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue