Пример #1
0
        public IActionResult GetMetric(string clientID, string metricID)
        {
            IActionResult result;
            Guid          clientIDGuid;

            if (StringUtils.GuidTryDecode(clientID, out clientIDGuid))
            {
                string       rootUrl = Request.GetRootUrl();
                ClientMetric metric  = BusinessLogicFactory.Metrics.GetMetric(clientIDGuid, metricID);
                if (metric != null)
                {
                    ServiceModels.Metric response = new ServiceModels.Metric(metric);
                    response.AddSelfLink(string.Concat(rootUrl, "/clients/", clientID, "/metrics/", metricID), false, false);
                    result = Request.GetObjectResult(response);
                }
                else
                {
                    result = new NotFoundResult();
                }
            }
            else
            {
                result = new NotFoundResult();
            }

            return(result);
        }
Пример #2
0
        private static void AddPageInfo <T>(Microsoft.AspNetCore.Http.HttpRequest request, ServiceModels.Metrics response, string baseUrl, List <T> metrics) where T : MetricBase
        {
            response.PageInfo = request.GetPageInfo(metrics.Count);
            int endIndex = response.PageInfo.StartIndex + response.PageInfo.ItemsCount;

            for (int index = response.PageInfo.StartIndex; index < endIndex; index++)
            {
                ServiceModels.Metric metric = new ServiceModels.Metric(metrics[index]);
                metric.AddSelfLink(string.Concat(baseUrl, metrics[index].Name), false, false);
                response.Add(metric);
            }
        }
Пример #3
0
        public IActionResult GetMetric(string metricID)
        {
            IActionResult      result;
            string             rootUrl = Request.GetRootUrl();
            OrganisationMetric metric  = BusinessLogicFactory.Metrics.GetMetric(User.GetOrganisationID(), metricID);

            if (metric != null)
            {
                ServiceModels.Metric response = new ServiceModels.Metric(metric);
                response.AddSelfLink(string.Concat(rootUrl, "/metrics/", metricID), false, false);
                result = Request.GetObjectResult(response);
            }
            else
            {
                result = new NotFoundResult();
            }
            return(result);
        }