/// <summary> /// 获取Job的分页列表信息 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <PagedResultDto <JobListDto> > GetPagedJobs(GetJobsInput input) { var query = _jobRepository.GetAllIncluding(c => c.Creator); query = query.WhereIf(!input.Filter.IsNullOrWhiteSpace(), c => c.Name.Contains(input.Filter)); var jobCount = await query.CountAsync(); var jobs = await query .OrderBy(input.Sorting) .PageBy(input) .ToListAsync(); var result = new List <JobListDto>(); var cj = await _myJobRepository.GetAll().WhereIf(input.CustomerId.HasValue, c => c.CustomerId == input.CustomerId.Value) .ToListAsync(); foreach (var job in jobs) { var model = job.MapTo <JobListDto>(); model.JoinCount = cj.Count(w => w.JobId == job.Id && w.VilidateState.HasValue && w.VilidateState.Value); model.JoinState = cj.Count(w => w.JobId == job.Id && (!w.VilidateState.HasValue || w.VilidateState.Value)) > 0; result.Add(model); } //var jobListDtos = ObjectMapper.Map<List <JobListDto>>(jobs); // var jobListDtos = jobs.MapTo<List<JobListDto>>(); return(new PagedResultDto <JobListDto>( jobCount, result )); }
public async Task <PagedResultDto <JobChanceListDto> > GetJobs(GetJobsInput input) { var jobs = await _jobRepository.GetAllListAsync(); int jobsCount = await _jobRepository.CountAsync(); var jobListDtos = jobs.MapTo <List <JobChanceListDto> >(); return(new PagedResultDto <JobChanceListDto>(jobsCount, jobListDtos)); }