api ปฏิเสธจ่ายเงิน get ไฟล์สมัครสอบ

This commit is contained in:
Kittapath 2023-04-09 04:22:04 +07:00
parent 9486ad160d
commit 5abeada4a6
32 changed files with 7513 additions and 394 deletions

View file

@ -49,6 +49,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
public async Task<CMSCandidate> GetsAsync()
{
var cms = await createCMS();
if (cms.LogoImg != null)
cms.LogoImg.Detail = _minioService.ImagesPath(cms.LogoImg.Id).Result;
if (cms.BannerImg != null)
cms.BannerImg.Detail = _minioService.ImagesPath(cms.BannerImg.Id).Result;
return cms;
}
@ -82,6 +89,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
var cms = await createCMS();
cms.NameTh = updated.NameTh;
cms.ShortName = updated.ShortName;
cms.NameEn = updated.NameEn;
cms.Description = updated.Description;
cms.LastUpdatedAt = DateTime.Now;
@ -129,9 +137,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
cms.ZipCode = subDistrict.ZipCode;
}
cms.NameTh = updated.About;
cms.NameEn = updated.Address;
cms.Description = updated.Telephone;
cms.About = updated.About;
cms.Address = updated.Address;
cms.Telephone = updated.Telephone;
cms.LastUpdatedAt = DateTime.Now;
cms.LastUpdateUserId = UserId ?? "";
cms.LastUpdateFullName = FullName ?? "";
@ -231,6 +239,168 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
await _context.SaveChangesAsync();
}
public async Task<HomePageResponseItem> GetHomePageAsync()
{
var cms = await createCMS();
var cmsCandidates = await _context.CMSCandidates.AsQueryable()
.Select(x => new HomePageResponseItem
{
Logo_url = x.LogoImg == null ? "" : x.LogoImg.Id.ToString(),
Title = x.NameTh,
Subtitle = x.NameEn,
Supervised = x.ShortName,
Telephone = x.Telephone,
Address = x.Address + " " + (x.SubDistrict == null ? "" : "แขวง" + x.SubDistrict.Name + " ") + (x.District == null ? "" : "เขต" + x.District.Name) + " " + (x.Province == null ? "" : x.Province.Name) + " " + (x.SubDistrict == null ? "" : x.SubDistrict.ZipCode),
Divisions = x.CMSAgencys.Select(s => new HomePageLinkResponseItem
{
Title = s.Name,
Url = s.Link,
}).ToList(),
Institutes = x.CMSGovernments.Select(s => new HomePageLinkResponseItem
{
Title = s.Name,
Url = s.Link,
}).ToList(),
})
.FirstOrDefaultAsync();
if (cmsCandidates == null)
throw new Exception(GlobalMessages.CMSNotFound);
if (cmsCandidates.Logo_url != null && cmsCandidates.Logo_url != "")
cmsCandidates.Logo_url = _minioService.ImagesPath(Guid.Parse(cmsCandidates.Logo_url)).Result;
return cmsCandidates;
}
public async Task<HomePageContentResponseItem> GetHomePageContentAsync()
{
var cms = await createCMS();
var cmsCandidates = await _context.CMSCandidates.AsQueryable()
.Select(x => new HomePageContentResponseItem
{
Content = x.Description,
Image = x.BannerImg == null ? "" : x.BannerImg.Id.ToString(),
})
.FirstOrDefaultAsync();
if (cmsCandidates == null)
throw new Exception(GlobalMessages.CMSNotFound);
if (cmsCandidates.Image != null && cmsCandidates.Image != "")
cmsCandidates.Image = _minioService.ImagesPath(Guid.Parse(cmsCandidates.Image)).Result;
return cmsCandidates;
}
public async Task<AboutPageContentResponseItem> GetAboutPageContentAsync()
{
var cms = await createCMS();
var cmsCandidates = await _context.CMSCandidates.AsQueryable()
.Select(x => new AboutPageContentResponseItem
{
Content = x.About,
})
.FirstOrDefaultAsync();
if (cmsCandidates == null)
throw new Exception(GlobalMessages.CMSNotFound);
return cmsCandidates;
}
public async Task<IEnumerable<CMSExamResponseItem?>> GetsCMSExamsAsync(int limit)
{
var cms = await createCMS();
var periodExams = await _context.PeriodExams.AsQueryable()
.Where(x => x.AnnouncementStartDate <= DateTime.Now)
.Where(x => x.AnnouncementEndDate >= DateTime.Now)
.Include(x => x.PeriodExamImages)
.Select(x => new CMSExamResponseItem
{
Id = x.Id.ToString(),
Category = "doctor",
Category_id = "doctor",
Start = x.ExamDate,
End = x.ExamDate,
Exam_date = x.ExamDate,
Announcement_date = x.AnnouncementStartDate,
Title = x.Name,
Image = x.PeriodExamImages.OrderBy(o => o.CreatedAt).FirstOrDefault() == null ?
"" :
x.PeriodExamImages.OrderBy(o => o.CreatedAt).FirstOrDefault().Document.Id.ToString(),
})
.ToListAsync();
if (limit > 0)
periodExams = periodExams.Take(limit).ToList();
var i = 0;
foreach (var item in periodExams)
{
if (periodExams[i].Image != null && periodExams[i].Image != "")
periodExams[i].Image = _minioService.ImagesPath(Guid.Parse(periodExams[i].Image)).Result;
i++;
}
return periodExams;
}
public async Task<CMSExamResponseItem> GetCMSExamsAsync(string examId)
{
var cms = await createCMS();
var periodExam = await _context.PeriodExams.AsQueryable()
.Where(x => x.Id == Guid.Parse(examId))
.Include(x => x.PeriodExamImages)
.Select(x => new CMSExamResponseItem
{
Id = x.Id.ToString(),
Category = "doctor",
Category_id = "doctor",
Start = x.ExamDate,
Title = x.Name,
Detail = x.Detail,
Images = x.PeriodExamImages.Select(s => new HomePageLinkResponseItem
{
Title = s.Document.FileName,
Url = s.Document.Id.ToString(),
}).ToList(),
Files = x.PeriodExamDocuments.Select(s => new HomePageLinkResponseItem
{
Title = s.Document.FileName,
Url = s.Document.Id.ToString(),
}).ToList(),
Positions = x.PositionExam.Select(s => new HomePageLinkResponseItem
{
Title = s.Id.ToString(),
Url = $"{x.Id}/{s.Id}",
}).ToList(),
})
.FirstOrDefaultAsync();
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
var i = 0;
foreach (var item in periodExam.Images)
{
if (periodExam.Images[i].Url != null && periodExam.Images[i].Url != "")
periodExam.Images[i].Url = _minioService.ImagesPath(Guid.Parse(periodExam.Images[i].Url)).Result;
i++;
}
i = 0;
foreach (var item in periodExam.Files)
{
if (periodExam.Files[i].Url != null && periodExam.Files[i].Url != "")
periodExam.Files[i].Url = _minioService.ImagesPath(Guid.Parse(periodExam.Files[i].Url)).Result;
i++;
}
return periodExam;
}
#endregion
}
}