// PUT api/Catalog/5 public async Task<IHttpActionResult> PutCatalog(int id, Catalog catalog) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != catalog.CatalogID) { return BadRequest(); } db.Entry(catalog).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CatalogExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostCatalog(Catalog catalog) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Catalogs.Add(catalog); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = catalog.CatalogID }, catalog); }