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