/// <summary> /// Support for replacing a ProductFamily /// </summary> public async Task<IHttpActionResult> Put([FromODataUri] int key, ProductFamily family) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (key != family.Id) { return BadRequest(); } _db.Entry(family).State = EntityState.Modified; try { await _db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!_db.ProductFamilies.Any(p => p.Id == key)) { return NotFound(); } throw; } return Ok(family); }
public async Task<IHttpActionResult> CreateProductFamily(ProductFamily productFamily) { if (!ModelState.IsValid) { return BadRequest(ModelState); } _db.ProductFamilies.Add(productFamily); await _db.SaveChangesAsync(); return Created(productFamily); }