public async Task <PagedModel <CfgDto> > GetPagedListV2(CfgSearchDto criteria) { Expression <Func <SysCfg, bool> > condition = it => true; if (!string.IsNullOrWhiteSpace(criteria.CfgName)) { condition = condition.And(it => it.CfgName.Contains(criteria.CfgName)); } if (!string.IsNullOrWhiteSpace(criteria.CfgValue)) { condition = condition.And(it => it.CfgValue.Contains(criteria.CfgValue)); } var result = await _unitOfWork.CfgRepository.PagedAsync( criteria.Page, criteria.Limit, condition, it => it.Id, true); var dto = CfgMapper.ToCfgDto(result); return(dto); }
public static CfgSearchDto ToCfgSearchDto(CfgListSearchRequest request) { var dto = new CfgSearchDto { CfgName = request.CfgName, CfgValue = request.CfgValue, Limit = request.Limit == 0 ? 20 : request.Limit, Page = request.Page == 0 ? 1 : request.Page }; return(dto); }
public async Task <PagedModel <CfgDto> > GetPagedList(CfgSearchDto criteria) { var searchCriteria = new SearchCriteria { Keyword = criteria.CfgName, SearchFields = new string[] { "CfgName" }, Offset = (criteria.Page - 1) * criteria.Limit, Count = criteria.Limit }; var result = await _cacheManager.GetOrCreatePagedListAsync <SysCfg>(searchCriteria, async options => { return(new List <SysCfg>()); }); var dto = CfgMapper.ToCfgDto(new PagedModel <SysCfg>()); return(dto); }
public async Task <PageModelDto <CfgDto> > GetPaged(CfgSearchDto searchDto) { //var result = new PageModelDto<CfgDto>(); Expression <Func <CfgDto, bool> > whereCondition = x => true; if (searchDto.CfgName.IsNotNullOrWhiteSpace()) { whereCondition = whereCondition.And(x => x.CfgName.Contains(searchDto.CfgName)); } if (searchDto.CfgName.IsNotNullOrWhiteSpace()) { whereCondition = whereCondition.And(x => x.CfgValue.Contains(searchDto.CfgValue)); } //var pagedModel = await _cfgRepository.PagedAsync(searchDto.PageIndex, searchDto.PageSize, whereCondition, c => c.CreateTime, false); var allCfgs = await this.GetAllFromCache(); var pagedCfgs = allCfgs.Where(whereCondition.Compile()) .OrderByDescending(x => x.CreateTime) .Skip((searchDto.PageIndex - 1) * searchDto.PageSize) .Take(searchDto.PageSize) .ToArray(); var result = new PageModelDto <CfgDto>() { Count = pagedCfgs.Count() , Data = pagedCfgs , TotalCount = allCfgs.Count , PageIndex = searchDto.PageIndex , PageSize = searchDto.PageSize , PageCount = ((allCfgs.Count + searchDto.PageSize - 1) / searchDto.PageSize) }; //result = _mapper.Map<PageModelDto<CfgDto>>(pagedModel); return(result); }
public async Task <PageModelDto <CfgDto> > GetPaged(CfgSearchDto searchDto) { PageModelDto <CfgDto> result = new PageModelDto <CfgDto>(); Expression <Func <SysCfg, bool> > whereCondition = x => true; if (!string.IsNullOrWhiteSpace(searchDto.CfgName)) { whereCondition = whereCondition.And(x => x.CfgName.Contains(searchDto.CfgName)); } if (!string.IsNullOrWhiteSpace(searchDto.CfgValue)) { whereCondition = whereCondition.And(x => x.CfgValue.Contains(searchDto.CfgValue)); } var pagedModel = await _cfgRepository.PagedAsync(searchDto.PageIndex, searchDto.PageSize, whereCondition, c => c.CreateTime, false); result = _mapper.Map <PageModelDto <CfgDto> >(pagedModel); return(result); }
public async Task <PageModelDto <CfgDto> > GetList([FromQuery] CfgSearchDto searchDto) { return(await _cfgAppService.GetPaged(searchDto)); }