public IHttpActionResult PostPersonel(Personel personel) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Personel.Add(personel); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = personel.PersonelId }, personel); }
public IHttpActionResult PutPersonel(int id, Personel personel) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != personel.PersonelId) { return BadRequest(); } db.Entry(personel).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PersonelExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }