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