public async Task <PaginationOutput <InterviewDto> > GetListAsync(QueryInterviewInput input) { CancellationToken.ThrowIfCancellationRequested(); if (input == null) { throw new ArgumentNullException(nameof(input)); } var query = from a in _context.Interviews join b in _context.Resumes on a.ResumeId equals b.Id join c in _context.Jobs on b.JobId equals c.Id join d in _context.Users on a.CreatorUserId equals d.Id join f in _context.Users on b.OwnerUserId equals f.Id select new InterviewDto() { Id = a.Id, Name = a.Name, AppointmentTime = a.AppointmentTime, Status = a.Status, JobName = c.Title, CreatorUserId = a.CreatorUserId, CreatorUserName = d.FullName, OwnerUserId = b.OwnerUserId, OwnerUserName = f.FullName, PhoneNumber = b.PhoneNumber, Remark = a.Remark, VisitedTime = a.VisitedTime, CreationTime = a.CreationTime }; if (!string.IsNullOrEmpty(input.Keyword)) { query = query.Where(w => w.Name.Contains(input.Keyword)); } if (input.StartTime.HasValue && input.EndTime.HasValue) { query = query.Where(w => w.AppointmentTime >= input.StartTime && w.AppointmentTime <= input.EndTime); } if (input.CreatorUserId.HasValue && input.CreatorUserId.Value != Guid.Empty) { query = query.Where(w => w.CreatorUserId == input.CreatorUserId); } if (input.Status.HasValue) { query = query.Where(w => w.Status == (InterviewStatus)input.Status.Value); } var totalCount = await query.CountAsync(CancellationToken); var totalSize = (int)Math.Ceiling(totalCount / (decimal)input.PageSize); var interviews = await query.OrderByDescending(o => o.CreationTime) .Skip((input.PageIndex - 1) * input.PageSize) .Take(input.PageSize) .ToListAsync(CancellationToken); return(new PaginationOutput <InterviewDto>(totalSize, interviews)); }
// 列表 public async Task <IActionResult> List(QueryInterviewInput input) { if (CustomSetting.DefaultOnlySeeMyselfData && !input.CreatorUserId.HasValue) { input.CreatorUserId = UserIdentifier.UserId; } var output = await _interviewQuerier.GetListAsync(input); var model = new QueryInterviewViewModel() { Output = new PaginationModel <InterviewDto>(output, input) }; return(await BuildListDisplayAsync(model)); }