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.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
[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
|
try
|
||||||
{
|
{
|
||||||
var items = await _periodExamService.GetsCandidateByStatusAsync(examId, status, page, pageSize);
|
var items = await _periodExamService.GetsCandidateByStatusAsync(examId, status, page, pageSize, keyword);
|
||||||
|
|
||||||
return Success(items);
|
return Success(items);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -675,7 +675,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
await _context.SaveChangesAsync();
|
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()
|
var periodExam = await _context.PeriodExams.AsQueryable()
|
||||||
.Where(x => x.CheckDisability == false)
|
.Where(x => x.CheckDisability == false)
|
||||||
|
|
@ -687,19 +687,32 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
if (status == "all")
|
if (status == "all")
|
||||||
{
|
{
|
||||||
var candidate = await _context.Candidates.AsQueryable()
|
var candidate = await _context.Candidates.AsQueryable()
|
||||||
// .Include(x => x.PositionExam)
|
.Include(x => x.PositionExam)
|
||||||
// .Include(x => x.ProfileImg)
|
.Include(x => x.ProfileImg)
|
||||||
.OrderByDescending(d => d.CreatedAt)
|
.OrderByDescending(d => d.CreatedAt)
|
||||||
.Where(x => x.PeriodExam == periodExam && x.RegisterDate != null && x.Status != "register" && x.Status != "rejectRegister")
|
.Where(x => x.PeriodExam == periodExam && x.RegisterDate != null && x.Status != "register" && x.Status != "rejectRegister")
|
||||||
.Skip((page - 1) * pageSize)
|
.Where(x =>
|
||||||
.Take(pageSize)
|
(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
|
.Select(x => new
|
||||||
{
|
{
|
||||||
Id = x.Id,
|
Id = x.Id,
|
||||||
PrefixName = x.PrefixName,
|
PrefixName = x.PrefixName,
|
||||||
FirstName = x.FirstName,
|
FirstName = x.FirstName,
|
||||||
LastName = x.LastName,
|
LastName = x.LastName,
|
||||||
// ProfileImg = x.ProfileImg,
|
ProfileImg = x.ProfileImg,
|
||||||
CitizenId = x.CitizenId,
|
CitizenId = x.CitizenId,
|
||||||
Number = x.Number,
|
Number = x.Number,
|
||||||
RegisterDate = x.RegisterDate,
|
RegisterDate = x.RegisterDate,
|
||||||
|
|
@ -714,28 +727,60 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
PositionLevelName = x.PositionExam == null ? null : x.PositionExam.PositionLevelName,
|
PositionLevelName = x.PositionExam == null ? null : x.PositionExam.PositionLevelName,
|
||||||
PositionName = x.PositionExam == null ? null : x.PositionExam.PositionName,
|
PositionName = x.PositionExam == null ? null : x.PositionExam.PositionName,
|
||||||
})
|
})
|
||||||
|
.Skip((page - 1) * pageSize)
|
||||||
|
.Take(pageSize)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
var _candidate = await _context.Candidates.AsQueryable()
|
var _candidate = await _context.Candidates.AsQueryable()
|
||||||
.Where(x => x.PeriodExam == periodExam && x.RegisterDate != null && x.Status != "register" && x.Status != "rejectRegister")
|
.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();
|
.CountAsync();
|
||||||
if (candidate.Where(x => x.Status == "done").FirstOrDefault() != null)
|
if (candidate.Where(x => x.Status == "done").FirstOrDefault() != null)
|
||||||
candidate = candidate.OrderBy(x => Convert.ToInt32(x.Number)).ToList();
|
candidate = candidate.OrderBy(x => Convert.ToInt32(x.Number)).ToList();
|
||||||
// var i = 0;
|
var i = 0;
|
||||||
// foreach (var item in candidate)
|
foreach (var item in candidate)
|
||||||
// {
|
{
|
||||||
// if (candidate[i].ProfileImg != null)
|
if (candidate[i].ProfileImg != null)
|
||||||
// candidate[i].ProfileImg.Detail = _minioService.ImagesPath(candidate[i].ProfileImg.Id).Result;
|
candidate[i].ProfileImg.Detail = _minioService.ImagesPath(candidate[i].ProfileImg.Id).Result;
|
||||||
// i++;
|
i++;
|
||||||
// }
|
}
|
||||||
return new { data = candidate, total = _candidate };
|
return new { data = candidate, total = _candidate };
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var candidate = await _context.Candidates.AsQueryable()
|
var candidate = await _context.Candidates.AsQueryable()
|
||||||
// .Include(x => x.PositionExam)
|
.Include(x => x.PositionExam)
|
||||||
// .Include(x => x.ProfileImg)
|
.Include(x => x.ProfileImg)
|
||||||
.OrderByDescending(d => d.CreatedAt)
|
.OrderByDescending(d => d.CreatedAt)
|
||||||
.Where(x => x.PeriodExam == periodExam && x.Status == status)
|
.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)
|
.Skip((page - 1) * pageSize)
|
||||||
.Take(pageSize)
|
.Take(pageSize)
|
||||||
.Select(x => new
|
.Select(x => new
|
||||||
|
|
@ -744,7 +789,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
PrefixName = x.PrefixName,
|
PrefixName = x.PrefixName,
|
||||||
FirstName = x.FirstName,
|
FirstName = x.FirstName,
|
||||||
LastName = x.LastName,
|
LastName = x.LastName,
|
||||||
// ProfileImg = x.ProfileImg,
|
ProfileImg = x.ProfileImg,
|
||||||
CitizenId = x.CitizenId,
|
CitizenId = x.CitizenId,
|
||||||
Number = x.Number,
|
Number = x.Number,
|
||||||
RegisterDate = x.RegisterDate,
|
RegisterDate = x.RegisterDate,
|
||||||
|
|
@ -762,16 +807,31 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
var _candidate = await _context.Candidates.AsQueryable()
|
var _candidate = await _context.Candidates.AsQueryable()
|
||||||
.Where(x => x.PeriodExam == periodExam && x.RegisterDate != null && x.Status != "register" && x.Status != "rejectRegister")
|
.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();
|
.CountAsync();
|
||||||
if (candidate.Where(x => x.Status == "done").FirstOrDefault() != null)
|
if (candidate.Where(x => x.Status == "done").FirstOrDefault() != null)
|
||||||
candidate = candidate.OrderBy(x => Convert.ToInt32(x.Number)).ToList();
|
candidate = candidate.OrderBy(x => Convert.ToInt32(x.Number)).ToList();
|
||||||
// var i = 0;
|
var i = 0;
|
||||||
// foreach (var item in candidate)
|
foreach (var item in candidate)
|
||||||
// {
|
{
|
||||||
// if (candidate[i].ProfileImg != null)
|
if (candidate[i].ProfileImg != null)
|
||||||
// candidate[i].ProfileImg.Detail = _minioService.ImagesPath(candidate[i].ProfileImg.Id).Result;
|
candidate[i].ProfileImg.Detail = _minioService.ImagesPath(candidate[i].ProfileImg.Id).Result;
|
||||||
// i++;
|
i++;
|
||||||
// }
|
}
|
||||||
return new { data = candidate, total = _candidate };
|
return new { data = candidate, total = _candidate };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue