Example #1
0
        public async Task <PagedResultDto <PlaqueStoreListDto> > GetPlaqueStore(GetPlaqueStoreInput input)
        {
            var query     = GetFilteredQuery(input);
            var userCount = await query.CountAsync();

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

            var plaqueStoresListDto = ObjectMapper.Map <List <PlaqueStoreListDto> >(plaqueStores);

            return(new PagedResultDto <PlaqueStoreListDto>(
                       userCount,
                       plaqueStoresListDto
                       ));
        }
Example #2
0
        private IQueryable <PlaqueStore> GetFilteredQuery(GetPlaqueStoreInput input)
        {
            long tempSearch = 0;

            try
            {
                tempSearch = Convert.ToInt64(input.Filter);
            }
            catch (Exception e)
            {
            }
            var query = QueryableExtensions.WhereIf(
                _plaqueStoreRepository.GetAll()
                .Include(x => x.Species)
                .Include(x => x.Manufacturer)
                .Include(x => x.FinishedPlaque),
                !input.Filter.IsNullOrWhiteSpace(), u =>
                (u.FromCode <= tempSearch &&
                 u.ToCode >= tempSearch) ||
                u.Species.Name.Contains(input.Filter) ||
                u.Manufacturer.Name.Contains(input.Filter));

            return(query);
        }