Esempio n. 1
0
        private static JArray CreateJsonResponse(HealthRecordItemCollection items)
        {
            JObject result    = new JObject();
            JObject resultObj = new JObject();
            JArray  itemArr   = new JArray();

            if (items != null)
            {
                foreach (HealthRecordItem item in items)
                {
                    ItemTypes.Weight weight = (ItemTypes.Weight)item;
                    JObject          itemW  = new JObject();
                    itemW["time"]   = weight.EffectiveDate.ToUniversalTime();
                    itemW["weight"] = weight.Value.Kilograms.ToString();
                    itemW["unit"]   = "kilograms";
                    itemArr.Add(itemW);
                }
            }
            result["count"]  = items.Count();
            result["result"] = itemArr;
            if (itemArr.Count > 0)
            {
                resultObj["status"]            = "ok";
                resultObj["getWeightResponse"] = result;
                return(itemArr);
            }
            else
            {
                resultObj["status"]            = "no content";
                resultObj["getWeightResponse"] = result;
                return(itemArr);
            }
        }
Esempio n. 2
0
        private static JArray CreateJsonResponse(HealthRecordItemCollection items)
        {
            JObject result    = new JObject();
            JObject resultObj = new JObject();
            JArray  itemArr   = new JArray();

            if (items != null)
            {
                foreach (HealthRecordItem item in items)
                {
                    VitalSigns vitalSign = (VitalSigns)item;
                    JObject    itemV     = new JObject();
                    itemV["unit"]        = "°C";
                    itemV["temperature"] = vitalSign.VitalSignsResults[0].Value;
                    itemV["time"]        = vitalSign.EffectiveDate.ToUniversalTime();
                    itemArr.Add(itemV);
                }
            }
            result["count"]  = items.Count();
            result["result"] = itemArr;
            if (itemArr.Count > 0)
            {
                resultObj["status"]            = "ok";
                resultObj["getWeightResponse"] = result;
                return(itemArr);
            }
            else
            {
                resultObj["status"]            = "no content";
                resultObj["getWeightResponse"] = result;
                return(itemArr);
            }
        }