public IHttpActionResult PutProductsJohn(int id, ProductsJohn productsJohn) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != productsJohn.ID) { return(BadRequest()); } db.Entry(productsJohn).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductsJohnExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetProductsJohn(int id) { ProductsJohn productsJohn = db.ProductsJohn.Find(id); if (productsJohn == null) { return(NotFound()); } return(Ok(productsJohn)); }
public IHttpActionResult PostProductsJohn(ProductsJohn productsJohn) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ProductsJohn.Add(productsJohn); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = productsJohn.ID }, productsJohn)); }
public IHttpActionResult DeleteProductsJohn(int id) { ProductsJohn productsJohn = db.ProductsJohn.Find(id); if (productsJohn == null) { return(NotFound()); } db.ProductsJohn.Remove(productsJohn); db.SaveChanges(); return(Ok(productsJohn)); }