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