public IHttpActionResult PutCompany(int id, Company company) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != company.Id) { return BadRequest(); } db.Entry(company).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CompanyExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostCompany(Company company) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Companies.Add(company); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = company.Id }, company); }