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