Esempio n. 1
0
        private IQueryable <RegionInfo> GetFilteredQuery(GetRegionInfoInput input)
        {
            var query = QueryableExtensions.WhereIf(
                _regionInfoRepository.GetAll()
                .Include(p => p.CityInfo)
                .ThenInclude(p => p.StateInfo),
                !input.Filter.IsNullOrWhiteSpace(), u =>
                u.CityInfo.StateInfo.Name.Contains(input.Filter) ||
                u.CityInfo.Name.Contains(input.Filter) ||
                u.Name.Contains(input.Filter) ||
                u.Code.Contains(input.Filter));

            return(query);
        }
Esempio n. 2
0
        public async Task <PagedResultDto <RegionInfoListDto> > GetRegionInfo(GetRegionInfoInput input)
        {
            var query     = GetFilteredQuery(input);
            var userCount = await query.CountAsync();

            var regionInfos = await query
                              .OrderBy(input.Sorting)
                              .PageBy(input)
                              .ToListAsync();

            var regionInfosListDto = ObjectMapper.Map <List <RegionInfoListDto> >(regionInfos);

            return(new PagedResultDto <RegionInfoListDto>(
                       userCount,
                       regionInfosListDto
                       ));
        }