public async Task<IHttpActionResult> PutAttendance(int id, Attendance attendance) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != attendance.Id) { return BadRequest(); } db.Entry(attendance).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AttendanceExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostAttendance(Attendance attendance) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Attendances.Add(attendance); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = attendance.Id }, attendance); }