public IHttpActionResult PutStepTestModel(int id, StepTestModel stepTestModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != stepTestModel.ID) { return(BadRequest()); } db.Entry(stepTestModel).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!StepTestModelExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetStepTestModel(int id) { StepTestModel stepTestModel = db.StepTests.Find(id); string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; if (stepTestModel == null || stepTestModel.Owner != owner) { return(NotFound()); } return(Ok(stepTestModel)); }
public IHttpActionResult PostStepTestModel(StepTestModel stepTestModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; stepTestModel.Owner = owner; //stepTestModel.Logged = DateTime.UtcNow; db.StepTests.Add(stepTestModel); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = stepTestModel.ID }, stepTestModel)); }