public IHttpActionResult PutAbsent(int id, Absent absent) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != absent.Id) { return BadRequest(); } db.Entry(absent).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AbsentExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostAbsent(Absent absent) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Absents.Add(absent); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = absent.Id }, absent); }