public async Task<IHttpActionResult> PutManufacturer(int id, Manufacturer manufacturer) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != manufacturer.ManufacturerId) { return BadRequest(); } db.Entry(manufacturer).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ManufacturerExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostManufacturer(Manufacturer manufacturer) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Manufacturers.Add(manufacturer); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = manufacturer.ManufacturerId }, manufacturer); }