//[AbpAuthorize(PermissionNames.AdminPage_DesiredLocationJob)] public virtual async Task <PagedResultDto <LocationJobDto> > GetAll(LocationJobFilterDto input) { var query = locationJobRepository.GetAll() .Include(p => p.JobSeeker) .Include(p => p.Cities) //.Include(p=>p.CategoryJob) .WhereIf(input.CityId != null, p => p.CityId == input.CityId) .WhereIf(input.JobSeekerId != null, p => p.JobSeekerId == input.JobSeekerId); var totalCount = await query.CountAsync(); query = ApplySorting(query, input); query = ApplyPaging(query, input); var entities = await query.ToListAsync(); return(new PagedResultDto <LocationJobDto>( totalCount, entities.Select(p => p.MapTo <LocationJobDto>()) .ToList() )); }
protected virtual IQueryable <DesiredLocationJob> ApplyPaging(IQueryable <DesiredLocationJob> query, LocationJobFilterDto input) { var pagedInput = input as IPagedResultRequest; if (pagedInput != null) { return(query.PageBy(pagedInput)); } var limitedInput = input as ILimitedResultRequest; if (limitedInput != null) { return(query.Take(limitedInput.MaxResultCount)); } return(query); }
protected virtual IQueryable <DesiredLocationJob> ApplySorting(IQueryable <DesiredLocationJob> query, LocationJobFilterDto input) { var sortInput = input as ISortedResultRequest; if (sortInput != null) { if (sortInput.Sorting.IsNotNullOrEmpty()) { return(query.OrderBy(sortInput.Sorting)); } } if (input is ILimitedResultRequest) { return(query.OrderByDescending(e => e.Id)); } return(query); }