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