Beispiel #1
0
        public IActionResult GetMetrics(
            [FromRoute] DateTimeOffset fromTime,
            [FromRoute] DateTimeOffset toTime)
        {
            _logger.LogInformation($"GetMetrics from:{fromTime} to:{toTime}");

            var metrics  = _repository.GetByTimePeriod(fromTime, toTime);
            var response = new NetworkMetricsResponse()
            {
                Metrics = new List <NetworkMetricDto>()
            };

            foreach (var metric in metrics)
            {
                response.Metrics.Add(_mapper.Map <NetworkMetricDto>(metric));
            }

            return(Ok(response));
        }
Beispiel #2
0
        public IActionResult GetMetricsByTimePeriod([FromRoute] NetworkMetricGetByTimePeriodRequest request)
        {
            logger.LogInformation($"From={request.From}|To={request.To}");
            var requestDAL = mapper.Map <DAL.Requests.NetworkMetricGetByTimePeriodRequest>(request);
            var metrics    = repository.GetByTimePeriod(requestDAL);
            var response   = new NetworkMetricsResponse();

            response.Metrics = metrics.Select(metric => mapper.Map <NetworkMetricDto>(metric)).ToList();
            return(Ok(response));
        }
Beispiel #3
0
        public IActionResult GetMetricsFromAgent(
            [FromRoute] int agentId,
            [FromRoute] DateTimeOffset fromTime,
            [FromRoute] DateTimeOffset toTime)
        {
            var metrics = _repository.GetByTimePeriod(agentId, fromTime, toTime);
            var response = new NetworkMetricsResponse()
            {
                Metrics = new List<NetworkMetricDto>()
            };

            foreach (var metric in metrics)
            {
                response.Metrics.Add(_mapper.Map<NetworkMetricDto>(metric));
            }

            return Ok(metrics);
        }
        public IActionResult GetMetricsNetworkByTimePeriod([FromBody] TimePeriod timePeriod)
        {
            var metrics = _repository.GetByTimePeriod(timePeriod);

            var response = new AllNetworkMetricsResponse()
            {
                Metrics = new List <NetworkMetricDto>()
            };

            foreach (var metric in metrics)
            {
                response.Metrics.Add(new NetworkMetricDto {
                    Time = metric.Time, Value = metric.Value, Id = metric.Id
                });
            }

            _logger.LogInformation($"All records of the period: {timePeriod.From} - {timePeriod.To} displayed successfully");

            return(Ok(response));
        }