add orderyby search data list

This commit is contained in:
Kittapath 2023-04-11 23:24:18 +07:00
parent 806fadc24f
commit e830632ac6
17 changed files with 3493 additions and 1239 deletions

View file

@ -49,11 +49,12 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
#region " Methods "
public async Task<IEnumerable<PeriodExamCandidateResponseItem>> GetsAsync(bool showAll = true)
public async Task<IEnumerable<PeriodExamCandidateResponseItem>> GetsAsync(string type, bool showAll = true)
{
return await _context.PeriodExams.AsQueryable()
.Where(p => p.IsActive)
.OrderBy(d => d.Name)
.Where(p => type.ToUpper() == "ALL" ? (p.AnnouncementExam == true || p.AnnouncementExam == false) : (type.ToUpper() == "EXAM" ? p.AnnouncementExam == false : p.AnnouncementExam == true))
.OrderByDescending(d => d.CreatedAt)
.Select(x => new PeriodExamCandidateResponseItem
{
ExamDate = x.ExamDate,
@ -73,6 +74,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
OrganizationName = x.OrganizationName,
PaymentEndDate = x.PaymentEndDate,
PaymentKrungThai = x.PaymentKrungThai,
AnnouncementExam = x.AnnouncementExam,
PaymentStartDate = x.PaymentStartDate,
RegisterEndDate = x.RegisterEndDate,
RegisterStartDate = x.RegisterStartDate,
@ -108,6 +110,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
OrganizationName = x.OrganizationName,
PaymentEndDate = x.PaymentEndDate,
PaymentKrungThai = x.PaymentKrungThai,
AnnouncementExam = x.AnnouncementExam,
PaymentStartDate = x.PaymentStartDate,
RegisterEndDate = x.RegisterEndDate,
RegisterStartDate = x.RegisterStartDate,
@ -234,6 +237,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
OrganizationId = inserted.OrganizationId,
OrganizationName = inserted.OrganizationName,
PaymentKrungThai = inserted.PaymentKrungThai,
AnnouncementExam = inserted.AnnouncementExam,
Detail = inserted.Detail,
Note = inserted.Note,
CreatedAt = DateTime.Now,
@ -318,6 +322,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
periodExam.OrganizationId = updated.OrganizationId;
periodExam.OrganizationName = updated.OrganizationName;
periodExam.PaymentKrungThai = updated.PaymentKrungThai;
// periodExam.AnnouncementExam = updated.AnnouncementExam;
periodExam.Detail = updated.Detail;
periodExam.Note = updated.Note;
periodExam.LastUpdatedAt = DateTime.Now;
@ -535,6 +540,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
var candidate = await _context.Candidates.AsQueryable()
.Include(x => x.ProfileImg)
.OrderByDescending(d => d.CreatedAt)
.Where(x => x.PeriodExam == periodExam && x.Status != "register" && x.Status != "rejectRegister")
.ToListAsync();
var i = 0;
@ -550,6 +556,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
var candidate = await _context.Candidates.AsQueryable()
.Include(x => x.ProfileImg)
.OrderByDescending(d => d.CreatedAt)
.Where(x => x.PeriodExam == periodExam && x.Status == status)
.ToListAsync();
var i = 0;
@ -698,6 +705,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
var document = await _context.CandidateDocuments.AsQueryable()
.Where(x => x.Candidate == candidate)
.OrderBy(d => d.CreatedAt)
.Select(x => new FileListResponse
{
Id = x.Document == null ? "" : x.Document.Id.ToString(),
@ -844,6 +852,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
candidates = await _context.Candidates
.AsQueryable()
.OrderBy(x => x.ExamIdenNumber)
.Where(x => x.PeriodExam == periodExam)
.Where(x => x.Status != "waiver")
.ToListAsync();
@ -852,6 +861,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
candidates = await _context.Candidates
.AsQueryable()
.OrderBy(x => x.ExamIdenNumber)
.Where(x => x.PeriodExam == periodExam)
.ToListAsync();
}