count paging total
This commit is contained in:
parent
10c695ae7e
commit
6d8e728c53
2 changed files with 85 additions and 25 deletions
|
|
@ -349,11 +349,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetsCandidateStatusAsync(string status, string examId, int page = 1, int pageSize = 25)
|
||||
public async Task<ActionResult<ResponseObject>> GetsCandidateStatusAsync(string status, string examId, int page = 1, int pageSize = 25, string keyword = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
var items = await _periodExamService.GetsCandidateByStatusAsync(examId, status, page, pageSize);
|
||||
var items = await _periodExamService.GetsCandidateByStatusAsync(examId, status, page, pageSize, keyword);
|
||||
|
||||
return Success(items);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -675,7 +675,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<dynamic> GetsCandidateByStatusAsync(string examId, string status, int page = 1, int pageSize = 25)
|
||||
public async Task<dynamic> GetsCandidateByStatusAsync(string examId, string status, int page = 1, int pageSize = 25, string keyword = "")
|
||||
{
|
||||
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||
.Where(x => x.CheckDisability == false)
|
||||
|
|
@ -687,19 +687,32 @@ 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")
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.Where(x =>
|
||||
(x.PositionExam == null || x.PositionExam.PositionLevelName == null ? true : x.PositionExam.PositionLevelName.Contains(keyword)) ||
|
||||
(x.PositionExam == null || x.PositionExam.PositionName == null ? true : x.PositionExam.PositionName.Contains(keyword)) ||
|
||||
(x.CitizenId == null ? true : x.CitizenId.Contains(keyword)) ||
|
||||
(x.PrefixName == null ? true : x.PrefixName.Contains(keyword)) ||
|
||||
(x.FirstName == null ? true : x.FirstName.Contains(keyword)) ||
|
||||
(x.LastName == null ? true : x.LastName.Contains(keyword)) ||
|
||||
(x.ExamIdenNumber == null ? true : x.ExamIdenNumber.Contains(keyword)) ||
|
||||
(x.SeatNumber == null ? true : x.SeatNumber.Contains(keyword)) ||
|
||||
(x.ResultA == null ? true : x.ResultA.Contains(keyword)) ||
|
||||
(x.ResultB == null ? true : x.ResultB.Contains(keyword)) ||
|
||||
(x.ResultC == null ? true : x.ResultC.Contains(keyword)) ||
|
||||
(x.Pass == null ? true : x.Pass.Contains(keyword))
|
||||
// (x.RegisterDate == null ? true : x.RegisterDate.Value.ToThaiShortDateTime().Contains(keyword))
|
||||
)
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,
|
||||
PrefixName = x.PrefixName,
|
||||
FirstName = x.FirstName,
|
||||
LastName = x.LastName,
|
||||
// ProfileImg = x.ProfileImg,
|
||||
ProfileImg = x.ProfileImg,
|
||||
CitizenId = x.CitizenId,
|
||||
Number = x.Number,
|
||||
RegisterDate = x.RegisterDate,
|
||||
|
|
@ -714,28 +727,60 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
PositionLevelName = x.PositionExam == null ? null : x.PositionExam.PositionLevelName,
|
||||
PositionName = x.PositionExam == null ? null : x.PositionExam.PositionName,
|
||||
})
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToListAsync();
|
||||
var _candidate = await _context.Candidates.AsQueryable()
|
||||
.Where(x => x.PeriodExam == periodExam && x.RegisterDate != null && x.Status != "register" && x.Status != "rejectRegister")
|
||||
.Where(x =>
|
||||
(x.PositionExam == null || x.PositionExam.PositionLevelName == null ? true : x.PositionExam.PositionLevelName.Contains(keyword)) ||
|
||||
(x.PositionExam == null || x.PositionExam.PositionName == null ? true : x.PositionExam.PositionName.Contains(keyword)) ||
|
||||
(x.CitizenId == null ? true : x.CitizenId.Contains(keyword)) ||
|
||||
(x.PrefixName == null ? true : x.PrefixName.Contains(keyword)) ||
|
||||
(x.FirstName == null ? true : x.FirstName.Contains(keyword)) ||
|
||||
(x.LastName == null ? true : x.LastName.Contains(keyword)) ||
|
||||
(x.ExamIdenNumber == null ? true : x.ExamIdenNumber.Contains(keyword)) ||
|
||||
(x.SeatNumber == null ? true : x.SeatNumber.Contains(keyword)) ||
|
||||
(x.ResultA == null ? true : x.ResultA.Contains(keyword)) ||
|
||||
(x.ResultB == null ? true : x.ResultB.Contains(keyword)) ||
|
||||
(x.ResultC == null ? true : x.ResultC.Contains(keyword)) ||
|
||||
(x.Pass == null ? true : x.Pass.Contains(keyword))
|
||||
// (x.RegisterDate == null ? true : x.RegisterDate.Value.ToThaiShortDateTime().Contains(keyword))
|
||||
)
|
||||
.CountAsync();
|
||||
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 new { data = candidate, total = _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)
|
||||
.Where(x =>
|
||||
(x.PositionExam == null || x.PositionExam.PositionLevelName == null ? true : x.PositionExam.PositionLevelName.Contains(keyword)) ||
|
||||
(x.PositionExam == null || x.PositionExam.PositionName == null ? true : x.PositionExam.PositionName.Contains(keyword)) ||
|
||||
(x.CitizenId == null ? true : x.CitizenId.Contains(keyword)) ||
|
||||
(x.PrefixName == null ? true : x.PrefixName.Contains(keyword)) ||
|
||||
(x.FirstName == null ? true : x.FirstName.Contains(keyword)) ||
|
||||
(x.LastName == null ? true : x.LastName.Contains(keyword)) ||
|
||||
(x.ExamIdenNumber == null ? true : x.ExamIdenNumber.Contains(keyword)) ||
|
||||
(x.SeatNumber == null ? true : x.SeatNumber.Contains(keyword)) ||
|
||||
(x.ResultA == null ? true : x.ResultA.Contains(keyword)) ||
|
||||
(x.ResultB == null ? true : x.ResultB.Contains(keyword)) ||
|
||||
(x.ResultC == null ? true : x.ResultC.Contains(keyword)) ||
|
||||
(x.Pass == null ? true : x.Pass.Contains(keyword))
|
||||
// (x.RegisterDate == null ? true : x.RegisterDate.Value.ToThaiShortDateTime().Contains(keyword))
|
||||
)
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.Select(x => new
|
||||
|
|
@ -744,7 +789,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
PrefixName = x.PrefixName,
|
||||
FirstName = x.FirstName,
|
||||
LastName = x.LastName,
|
||||
// ProfileImg = x.ProfileImg,
|
||||
ProfileImg = x.ProfileImg,
|
||||
CitizenId = x.CitizenId,
|
||||
Number = x.Number,
|
||||
RegisterDate = x.RegisterDate,
|
||||
|
|
@ -762,16 +807,31 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
|||
.ToListAsync();
|
||||
var _candidate = await _context.Candidates.AsQueryable()
|
||||
.Where(x => x.PeriodExam == periodExam && x.RegisterDate != null && x.Status != "register" && x.Status != "rejectRegister")
|
||||
.Where(x =>
|
||||
(x.PositionExam == null || x.PositionExam.PositionLevelName == null ? true : x.PositionExam.PositionLevelName.Contains(keyword)) ||
|
||||
(x.PositionExam == null || x.PositionExam.PositionName == null ? true : x.PositionExam.PositionName.Contains(keyword)) ||
|
||||
(x.CitizenId == null ? true : x.CitizenId.Contains(keyword)) ||
|
||||
(x.PrefixName == null ? true : x.PrefixName.Contains(keyword)) ||
|
||||
(x.FirstName == null ? true : x.FirstName.Contains(keyword)) ||
|
||||
(x.LastName == null ? true : x.LastName.Contains(keyword)) ||
|
||||
(x.ExamIdenNumber == null ? true : x.ExamIdenNumber.Contains(keyword)) ||
|
||||
(x.SeatNumber == null ? true : x.SeatNumber.Contains(keyword)) ||
|
||||
(x.ResultA == null ? true : x.ResultA.Contains(keyword)) ||
|
||||
(x.ResultB == null ? true : x.ResultB.Contains(keyword)) ||
|
||||
(x.ResultC == null ? true : x.ResultC.Contains(keyword)) ||
|
||||
(x.Pass == null ? true : x.Pass.Contains(keyword))
|
||||
// (x.RegisterDate == null ? true : x.RegisterDate.Value.ToThaiShortDateTime().Contains(keyword))
|
||||
)
|
||||
.CountAsync();
|
||||
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 new { data = candidate, total = _candidate };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue