public IActionResult GetAll() { var metrics = _repository.GetAll(); var response = new AllCpuMetricsResponse() { Metrics = new List <CpuMetricManagerDto>() }; foreach (var metric in metrics) { response.Metrics.Add(_mapper.Map <CpuMetricManagerDto>(metric)); } return(Ok(response)); }
public IActionResult GetAllMetrics() { IList <CpuMetricModel> metrics = _repository.GetAll(); var response = new AllCpuMetricsResponse() { Metrics = new List <CpuMetricDto>() }; foreach (var metric in metrics) { response.Metrics.Add(_mapper.Map <CpuMetricDto>(metric)); } _logger.LogInformation($"Запрос всех метрик Cpu"); return(Ok(response)); }
public IActionResult GetAll() { _logger.LogInformation($"Метод GetAll"); IList <CpuMetrics> metrics = _repository.GetAll(); var response = new AllCpuMetricsApiResponse() { Metrics = new List <CpuMetricsDto>() }; if (metrics != null) { foreach (var metric in metrics) { response.Metrics.Add(_mapper.Map <CpuMetricsDto>(metric)); } } return(Ok(response)); }
public IActionResult GetAll() { var metrics = repository.GetAll(); var response = new AllCpuMetricsResponse() { Metrics = new List <CpuMetricDto>() }; foreach (var metric in metrics) { response.Metrics.Add(new CpuMetricDto { Time = metric.Time, Value = metric.Value, Id = metric.Id }); } return(Ok(response)); }
public IActionResult GetAll() { _logger.LogDebug("GetAll : без параметров"); var metrics = _repository.GetAll(); var response = new AllCpuMetricsResponse() { Metrics = new List <CpuMetricDto>() }; foreach (var metric in metrics) { response.Metrics.Add(_mapper.Map <CpuMetricDto>(metric)); } return(Ok(response)); }
public IActionResult GetAll() { var metrics = repository.GetAll(); var response = new AllCpuMetricsResponse() { Metrics = new List <CpuMetricDto>() }; foreach (var metric in metrics) { response.Metrics.Add(new CpuMetricDto { Time = metric.Time.Minutes, Value = metric.Value, Id = metric.Id }); _logger.LogInformation($"GetAll: Time - {metric.Time.Minutes}, Value - {metric.Value}"); } return(Ok(response)); }
public IActionResult GetAll() { var metrics = _repository.GetAll(); var response = new AllCpuMetricsResponse() { Metrics = new List <CpuMetricDto>() }; foreach (var metric in metrics) { response.Metrics.Add(new CpuMetricDto { Time = metric.Time, Value = metric.Value, Id = metric.Id }); } _logger.LogInformation($"All records were successfully displayed"); return(Ok(response)); }
public IActionResult GetAll() { // задаем конфигурацию для мапера. Первый обобщенный параметр -- тип объекта источника, второй -- тип объекта в который перетекут данные из источника var config = new MapperConfiguration(cfg => cfg.CreateMap <CpuMetric, CpuMetricDto>()); var m = config.CreateMapper(); IList <CpuMetric> metrics = _repository.GetAll(); var response = new CpuAllMetricsResponse() { Metrics = new List <CpuMetricDto>() }; foreach (var metric in metrics) { // добавляем объекты в ответ при помощи мапера response.Metrics.Add(m.Map <CpuMetricDto>(metric)); } _logger.LogInformation(string.Concat("GetAll_CPU")); return(Ok(response)); }