// POST api/ProductCategory public HttpResponseMessage PostProductCategory(ProductCategory productcategory) { if (ModelState.IsValid) { repository.PostProductCategory(productcategory); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, productcategory); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = productcategory.Id })); return response; } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
public void RemoveProductCategories(ProductCategory product) { db.ProductCategories.Remove(product); }
public void PutProductCategory(int id, ProductCategory productcategory) { db.Entry(productcategory).State = EntityState.Modified; Save(); }
public void PostProductCategory(ProductCategory productcategory) { db.ProductCategories.Add(productcategory); db.SaveChanges(); }
// PUT api/ProductCategory/5 public HttpResponseMessage PutProductCategory(int id, ProductCategory productcategory) { if (ModelState.IsValid && id == productcategory.Id) { try { repository.PutProductCategory(id, productcategory); } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.NotFound); } return Request.CreateResponse(HttpStatusCode.OK); } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }