protected virtual IQueryable <Career> ApplyPaging(IQueryable <Career> query, CareerFilterDto 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); }
//[AbpAuthorize(PermissionNames.AdminPage_Career)] public virtual async Task <PagedResultDto <CareerDto> > GetAll(CareerFilterDto input) { var query = careerRepository.GetAll() .WhereIf(input.Id != null, p => p.Id == input.Id); var totalCount = await query.CountAsync(); query = ApplySorting(query, input); query = ApplyPaging(query, input); var entities = await query.ToListAsync(); return(new PagedResultDto <CareerDto>( totalCount, entities.Select(p => p.MapTo <CareerDto>()) .ToList() )); }
protected virtual IQueryable <Career> ApplySorting(IQueryable <Career> query, CareerFilterDto 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); }