Exemplo n.º 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());
        }
Exemplo n.º 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));
        }
Exemplo n.º 3
0
 public async Task <IEnumerable <Measurement> > GetListAsync(ResourceParameters.Measurements measurementsResourceParameters)
 {
     return(await _dal.GetListAsync(measurementsResourceParameters));
 }