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