Exemple #1
0
        public PageResponse <MeasurementItem> GetMeasurementList(MeasurementListRequest request)
        {
            PageResponse <MeasurementItem> response = new PageResponse <MeasurementItem>();
            var queryable = _measurementRepository.GetMeasurements(request.Query.StartDate, request.Query.EndDate, request.Query.Jsn, request.Query.ShopId, request.Query.MeasurementPointId).Select(m => (MeasurementItem)m);

            if (request.Pagination != null)
            {
                Func <MeasurementItem, int> orderFunction = null;
                if (request.Pagination.OrderBy == "id")
                {
                    orderFunction = OrderById;
                }
                PaginationResponse paginationResponse;
                response.Data = GetPage(queryable,
                                        new Pagination <MeasurementItem, int>
                {
                    CurrentPage   = request.Pagination.CurrentPage,
                    PageLength    = request.Pagination.PageSize,
                    RequestedPage = request.Pagination.Page,
                    OrderFunction = orderFunction
                }, out paginationResponse);
                response.Pagination         = paginationResponse;
                response.Pagination.OrderBy = request.Pagination.OrderBy;
                return(response);
            }
            response.Data = queryable.ToList();
            return(response);
        }
Exemple #2
0
        public async Task <IEnumerable <Measurement> > GetMeasurements(string deviceUuid, int hours)
        {
            if (hours > 24 * 31)
            {
                return(Enumerable.Empty <Measurement>());
            }

            var measurements = await _measurementRepository.GetMeasurements(deviceUuid, hours);

            return(FilterMeasurements(measurements, MaximumNumberOfMeasurements));
        }
Exemple #3
0
        public ActionResult <IEnumerable <Entities.Measurement> > GetMeasurements()
        {
            var measurements = _measurementsRepository.GetMeasurements();

            return(Ok(measurements));
        }
Exemple #4
0
 public List <MeasurementDto> GetMeasurements(string userId)
 {
     return(_repository.GetMeasurements(userId));
 }