public async Task<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 { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompanyExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostCompany(Company company) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Companies.Add(company); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = company.Id }, company); }