public IHttpActionResult PutEmployee(int id, Employees 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(Employees employee) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Employees.Add(employee); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = employee.EmployeeID }, employee); }