Ejemplo n.º 1
0
        public void should_read_by_token()
        {
            var metrics      = _metricsService.Read(_authProtocol, _url, false).Result;
            var savedMetrics = _emrMetricRepository.GetAll().First();

            Assert.NotNull(metrics);

            Assert.NotNull(savedMetrics);

            Assert.AreEqual(metrics.EmrName, savedMetrics.EmrName);
            Assert.AreEqual(metrics.EmrVersion, savedMetrics.EmrVersion);

            Console.WriteLine(metrics);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> LoadMetric([FromBody] EmrSystem entity)
        {
            if (null == entity)
            {
                return(BadRequest());
            }

            var restProtocol = entity.RestProtocols.FirstOrDefault();

            if (null == restProtocol)
            {
                return(BadRequest());
            }

            if (null == restProtocol.Metric)
            {
                return(BadRequest());
            }

            try
            {
                var metric = await _metricsService.Read(restProtocol, restProtocol.Metric.EndPoint);

                if (null == metric)
                {
                    throw new Exception("could not load EMR metrics");
                }

                return(Ok(metric));
            }
            catch (Exception e)
            {
                var msg = $"Error loading {nameof(EmrMetric)}";
                Log.Error(msg);
                Log.Error($"{e}");
                return(StatusCode(500, msg));
            }
        }