public async Task<IHttpActionResult> PutEmployeeNextOfKin(int id, EmployeeNextOfKin employeeNextOfKin) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != employeeNextOfKin.Id) { return BadRequest(); } db.Entry(employeeNextOfKin).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeNextOfKinExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostEmployeeNextOfKin(EmployeeNextOfKin employeeNextOfKin) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.EmployeeNextOfKins.Add(employeeNextOfKin); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = employeeNextOfKin.Id }, employeeNextOfKin); }