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)); }
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)); }
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)); }