public async Task<IHttpActionResult> PutProductCategory(int id, ProductCategory productCategory) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != productCategory.ProductCategoryID) { return BadRequest(); } db.Entry(productCategory).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductCategoryExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostProductCategory(ProductCategory productCategory) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.ProductCategories.Add(productCategory); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = productCategory.ProductCategoryID }, productCategory); }