Пример #1
0
        public async Task <IEnumerable <Measurement> > GetListAsync(ResourceParameters.Measurements resourceParameters)
        {
            ParameterChecks.CheckResourceParameters(resourceParameters);

            var collection = _context.Measurements.AsQueryable <Measurement>();

            if (!string.IsNullOrWhiteSpace(resourceParameters.SearchQuery))
            {
                collection = collection.Where(i => i.Name.Contains(resourceParameters.SearchQuery.Trim()));
            }

            if (!string.IsNullOrWhiteSpace(resourceParameters.OrderBy))
            {
                collection = resourceParameters.SortAsc ? collection.OrderBy(i => i.Name) : collection.OrderByDescending(i => i.Name);
            }

            return(await collection.Skip((resourceParameters.PageNumber - 1) *resourceParameters.PageSize).Take(resourceParameters.PageSize).ToListAsync());
        }
Пример #2
0
        public async Task <ActionResult <IEnumerable <MeasurementDto> > > GetMeasurementsAsync([FromQuery] ResourceParameters.Measurements measurementsResourceParameters)
        {
            var measurementEntities = await _measurements.GetListAsync(measurementsResourceParameters);

            var measurementDtosList = _mapper.Map <IEnumerable <MeasurementDto> >(measurementEntities);

            return(Ok(measurementDtosList));
        }
Пример #3
0
 public async Task <IEnumerable <Measurement> > GetListAsync(ResourceParameters.Measurements measurementsResourceParameters)
 {
     return(await _dal.GetListAsync(measurementsResourceParameters));
 }