Beispiel #1
0
        public HttpResponseMessage GetUserHeights()
        {
            string wctoken = ((string[])(Request.Headers.GetValues("CHbaseToken")))[0];

            Guid app_id = new Guid("d13d9244-8f0c-44e7-8498-682dc9befc23");

            PersonInfo personInfo = WebApplicationUtilities.GetPersonInfo(wctoken, app_id);

            List <HeightModel> heightMeasurements = HeightHelper.GetValues <HeightModel>(Height.TypeId, personInfo);

            var message = Request.CreateResponse(HttpStatusCode.OK, heightMeasurements);

            return(message);
        }
Beispiel #2
0
        public HttpResponseMessage AddUserHeight([FromBody] HeightModel heightObj)
        {
            Guid app_id = new Guid("d13d9244-8f0c-44e7-8498-682dc9befc23");

            string wctoken = ((string[])(Request.Headers.GetValues("CHbaseToken")))[0];

            PersonInfo personInfo = WebApplicationUtilities.GetPersonInfo(wctoken, app_id);

            HeightHelper.AddRandomHeightEntry(personInfo);

            var message = Request.CreateResponse(HttpStatusCode.OK);

            return(message);
        }
        public HttpResponseMessage GetUserFormDatasApi(string formName)
        {
            string        accessToken = Request.Headers.Authorization.Parameter;
            FormTypeModel formFields  = FormTypeHelper.GetFormFields(formName);

            if (formFields.FormType.ToLower() == "height")
            {
                string wctoken = ((string[])(Request.Headers.GetValues("CHbaseToken")))[0];

                Guid app_id = new Guid("d13d9244-8f0c-44e7-8498-682dc9befc23");

                PersonInfo personInfo = WebApplicationUtilities.GetPersonInfo(wctoken, app_id);

                List <HeightModel> heightMeasurements = HeightHelper.GetValues <HeightModel>(Height.TypeId, personInfo);

                List <FormDataModel> formDatas = new List <FormDataModel>();



                int i = 1000;

                foreach (HeightModel heightMeasurement in heightMeasurements)
                {
                    FormDataModel         formdata = new FormDataModel();
                    List <DataValueModel> datas    = new List <DataValueModel>();
                    DataValueModel        data1    = new DataValueModel();
                    DataValueModel        data2    = new DataValueModel();
                    data1.Name  = "Meters";
                    data1.Value = heightMeasurement.Meters.ToString();
                    datas.Add(data1);
                    data2.Name  = "When";
                    data2.Value = heightMeasurement.When.ToString();
                    datas.Add(data2);
                    formdata.FormId   = i;
                    formdata.FormName = formFields.FormName;
                    formdata.FormType = formFields.FormType;
                    formdata.FormData = datas;

                    formDatas.Add(formdata);
                    i += 1;
                }

                var message = Request.CreateResponse(HttpStatusCode.OK, formDatas);

                return(message);
            }

            else
            {
                UserObjectModel userObj = TokenHelper.getUserByAccessToken(accessToken);
                if (userObj != null)
                {
                    List <FormDataModel> dataList = UserSpecificFormsHelper.GetUserFormDataList(userObj.UserId, formName);
                    var message = Request.CreateResponse(HttpStatusCode.OK, dataList);
                    return(message);
                }
                else
                {
                    throw new Exception("Invalid User");
                }
            }
        }