Пример #1
0
        public IHttpActionResult PutStepTestHeartRateModel(int id, StepTestHeartRateModel stepTestHeartRateModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public IHttpActionResult GetStepTestHeartRateModel(int id)
        {
            StepTestHeartRateModel stepTestHeartRateModel = db.StepTestHeartRates.Find(id);
            string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;

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

            return(Ok(stepTestHeartRateModel));
        }
Пример #3
0
        public IHttpActionResult PostStepTestHeartRateModel(StepTestHeartRateModel stepTestHeartRateModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;

            stepTestHeartRateModel.Owner = owner;
            db.StepTestHeartRates.Add(stepTestHeartRateModel);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = stepTestHeartRateModel.ID }, stepTestHeartRateModel));
        }