public IHttpActionResult PutHeightModel(int id, HeightModel heightModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != heightModel.ID)
            {
                return(BadRequest());
            }

            db.Entry(heightModel).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HeightModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult GetHeightModel(int id)
        {
            HeightModel heightModel = db.Heights.Find(id);
            string      owner       = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;

            if (heightModel == null || heightModel.Owner != owner)
            {
                return(NotFound());
            }

            return(Ok(heightModel));
        }
Example #3
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 IHttpActionResult PostHeightModel(HeightModel heightModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;

            heightModel.Owner = owner;
            //heightModel.Logged = DateTime.UtcNow;
            db.Heights.Add(heightModel);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = heightModel.ID }, heightModel));
        }
Example #5
0
        public static List <HeightModel> GetValues <T>(Guid typeID, PersonInfo personInfo) where T : HeightModel
        {
            HealthRecordSearcher searcher = personInfo.SelectedRecord.CreateSearcher();

            HealthRecordFilter filter = new HealthRecordFilter(typeID);

            searcher.Filters.Add(filter);

            HealthRecordItemCollection items = searcher.GetMatchingItems()[0];

            List <HeightModel> typedList = new List <HeightModel>();

            foreach (HealthRecordItem item in items)
            {
                Height      itemObj   = (Height)item;
                HeightModel heightObj = new HeightModel(itemObj.Value.Meters, itemObj.When);
                typedList.Add(heightObj);
            }

            return(typedList);
        }