diff --git a/Services/PeriodExamService.cs b/Services/PeriodExamService.cs index af2b18c..22675ad 100644 --- a/Services/PeriodExamService.cs +++ b/Services/PeriodExamService.cs @@ -675,7 +675,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services await _context.SaveChangesAsync(); } - public async Task> GetsCandidateByStatusAsync(string examId, string status) + public async Task> GetsCandidateByStatusAsync(string examId, string status) { var periodExam = await _context.PeriodExams.AsQueryable() .Where(x => x.CheckDisability == false) @@ -687,39 +687,81 @@ namespace BMA.EHR.Recurit.Exam.Service.Services if (status == "all") { var candidate = await _context.Candidates.AsQueryable() - .Include(x => x.PositionExam) - .Include(x => x.ProfileImg) + // .Include(x => x.PositionExam) + // .Include(x => x.ProfileImg) .OrderByDescending(d => d.CreatedAt) .Where(x => x.PeriodExam == periodExam && x.RegisterDate != null && x.Status != "register" && x.Status != "rejectRegister") + .Select(x => new + { + Id = x.Id, + PrefixName = x.PrefixName, + FirstName = x.FirstName, + LastName = x.LastName, + // ProfileImg = x.ProfileImg, + CitizenId = x.CitizenId, + Number = x.Number, + RegisterDate = x.RegisterDate, + ExamIdenNumber = x.ExamIdenNumber, + SeatNumber = x.SeatNumber, + ResultA = x.ResultA, + ResultB = x.ResultB, + ResultC = x.ResultC, + Pass = x.Pass, + Email = x.Email, + Status = x.Status, + PositionLevelName = x.PositionExam == null ? null : x.PositionExam.PositionLevelName, + PositionName = x.PositionExam == null ? null : x.PositionExam.PositionName, + }) .ToListAsync(); if (candidate.Where(x => x.Status == "done").FirstOrDefault() != null) candidate = candidate.OrderBy(x => Convert.ToInt32(x.Number)).ToList(); - var i = 0; - foreach (var item in candidate) - { - if (candidate[i].ProfileImg != null) - candidate[i].ProfileImg.Detail = _minioService.ImagesPath(candidate[i].ProfileImg.Id).Result; - i++; - } + // var i = 0; + // foreach (var item in candidate) + // { + // if (candidate[i].ProfileImg != null) + // candidate[i].ProfileImg.Detail = _minioService.ImagesPath(candidate[i].ProfileImg.Id).Result; + // i++; + // } return candidate; } else { var candidate = await _context.Candidates.AsQueryable() - .Include(x => x.PositionExam) - .Include(x => x.ProfileImg) + // .Include(x => x.PositionExam) + // .Include(x => x.ProfileImg) .OrderByDescending(d => d.CreatedAt) .Where(x => x.PeriodExam == periodExam && x.Status == status) + .Select(x => new + { + Id = x.Id, + PrefixName = x.PrefixName, + FirstName = x.FirstName, + LastName = x.LastName, + // ProfileImg = x.ProfileImg, + CitizenId = x.CitizenId, + Number = x.Number, + RegisterDate = x.RegisterDate, + ExamIdenNumber = x.ExamIdenNumber, + SeatNumber = x.SeatNumber, + ResultA = x.ResultA, + ResultB = x.ResultB, + ResultC = x.ResultC, + Pass = x.Pass, + Email = x.Email, + Status = x.Status, + PositionLevelName = x.PositionExam == null ? null : x.PositionExam.PositionLevelName, + PositionName = x.PositionExam == null ? null : x.PositionExam.PositionName, + }) .ToListAsync(); if (candidate.Where(x => x.Status == "done").FirstOrDefault() != null) candidate = candidate.OrderBy(x => Convert.ToInt32(x.Number)).ToList(); - var i = 0; - foreach (var item in candidate) - { - if (candidate[i].ProfileImg != null) - candidate[i].ProfileImg.Detail = _minioService.ImagesPath(candidate[i].ProfileImg.Id).Result; - i++; - } + // var i = 0; + // foreach (var item in candidate) + // { + // if (candidate[i].ProfileImg != null) + // candidate[i].ProfileImg.Detail = _minioService.ImagesPath(candidate[i].ProfileImg.Id).Result; + // i++; + // } return candidate; } }