Пример #1
0
        public ActionResult RecordMetric()
        {
            MetricsMainModel model = new MetricsMainModel();

            model.MetricClasses = GetMetricClasses().Select(a =>
                                                            new SelectListItem
            {
                Value = a.Id.ToString(),
                Text  = a.Class
            }).ToList();

            model.MetricTypes = new List <SelectListItem>();

            return(View(model));
        }
Пример #2
0
        private string AddNewMetric(MetricsMainModel obj)
        {
            string JsonQuery = "{";

            if (Session["ClientId"] == null && !(User.IsInRole("System Administrator") || User.IsInRole("Coach")))
            {
                string loggedInUserId = HttpContext.GetOwinContext().Authentication.User.Claims.First(x => x.Type == ClaimTypes.NameIdentifier).Value;

                JsonQuery += "\"UserId\":\"" + loggedInUserId + "\",";
            }
            else
            {
                JsonQuery += "\"UserId\":\"" + Session["ClientId"].ToString() + "\",";
            }


            JsonQuery += "\"MetricClass\":" + obj.MetricClass + "," +
                         "\"MetricType\":\"" + obj.MetricType + "\"," +
                         "\"Quantity\":" + obj.Quantity.ToString("0.#############", System.Globalization.CultureInfo.InvariantCulture) + "," +
                         "\"Timestamp\":\"" + obj.Timestamp + "\"" +
                         "}";


            JObject jObj = QueryMicroService(AddNewMetricRecordEndpoint, "POST", JsonQuery);

            string message = "";

            if (jObj["status"].ToString() == "OK")
            {
                message = jObj["result"].ToString();
            }
            else
            {
                message = $"Failed to record metric.\n{jObj["result"].ToString()}";
            }

            return(message);
        }
Пример #3
0
 public ActionResult AddMetric(MetricsMainModel obj)
 {
     return(Json(new { result = AddNewMetric(obj) }, JsonRequestBehavior.AllowGet));
 }