예제 #1
0
        public IActionResult GetMetrics(string clientID)
        {
            IActionResult result;
            Guid          clientIDGuid;

            if (StringUtils.GuidTryDecode(clientID, out clientIDGuid))
            {
                Model.Client client = BusinessLogicFactory.Clients.GetClient(clientIDGuid);
                if (client != null)
                {
                    ServiceModels.Metrics     response = new ServiceModels.Metrics();
                    List <Model.ClientMetric> metrics  = BusinessLogicFactory.Metrics.GetMetrics(client.ClientID);
                    AddPageInfo(Request, response, string.Concat(Request.GetRootUrl(), "/clients/", clientID, "/metrics/"), metrics);
                    result = Request.GetObjectResult(response);
                }
                else
                {
                    result = new NotFoundResult();
                }
            }
            else
            {
                result = new NotFoundResult();
            }
            return(result);
        }
예제 #2
0
        public IActionResult GetMetrics()
        {
            IActionResult result;

            ServiceModels.Metrics           response = new ServiceModels.Metrics();
            List <Model.OrganisationMetric> metrics  = BusinessLogicFactory.Metrics.GetMetrics(User.GetOrganisationID());

            AddPageInfo(Request, response, string.Concat(Request.GetRootUrl(), "/metrics/"), metrics);
            result = Request.GetObjectResult(response);
            return(result);
        }
예제 #3
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);
            }
        }