// PUT api/Employees/5 public IHttpActionResult PutEmployee(int id, Employee employee) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != employee.EmployeeID) { return BadRequest(); } db.Entry(employee).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostEmployee(Employee employee) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Employees.Add(employee); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = employee.EmployeeID }, employee); }