public async Task<IHttpActionResult> Putproduct(int productId, product product) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (productId != product.productId) { return BadRequest(); } db.Entry(product).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!productExists(productId)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> Postproduct(product product) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.product.Add(product); await db.SaveChangesAsync(); return Created("api/products", product); }