public IHttpActionResult PostEmployeeInfo(EmployeeInfo employeeInfo) { if (!ModelState.IsValid) { return BadRequest(ModelState); } context.EmployeeInfo.Add(employeeInfo); context.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = employeeInfo.Id }, employeeInfo); }
public IHttpActionResult PutEmployeeInfo(int id, EmployeeInfo employeeInfo) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != employeeInfo.Id) { return BadRequest(); } context.Entry(employeeInfo).State = EntityState.Modified; try { context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EmployeeInfoExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }