public IHttpActionResult PutAppointment(int id, Appointment appointment) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != appointment.ID) { return BadRequest(); } db.Entry(appointment).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AppointmentExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostAppointment(Appointment appointment) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Appointments.Add(appointment); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = appointment.ID }, appointment); }