public async Task <IHttpActionResult> PutDoctorPatientRelation(int id, DoctorPatientRelation doctorPatientRelation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != doctorPatientRelation.RelationID) { return(BadRequest()); } db.Entry(doctorPatientRelation).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DoctorPatientRelationExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetDoctorPatientRelation(int id) { DoctorPatientRelation doctorPatientRelation = await db.DoctorPatientRelations.FindAsync(id); if (doctorPatientRelation == null) { return(NotFound()); } return(Ok(doctorPatientRelation)); }
public async Task <IHttpActionResult> PostDoctorPatientRelation(DoctorPatientRelation doctorPatientRelation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.DoctorPatientRelations.Add(doctorPatientRelation); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = doctorPatientRelation.RelationID }, doctorPatientRelation)); }
public async Task <IHttpActionResult> DeleteDoctorPatientRelation(int id) { DoctorPatientRelation doctorPatientRelation = await db.DoctorPatientRelations.FindAsync(id); if (doctorPatientRelation == null) { return(NotFound()); } db.DoctorPatientRelations.Remove(doctorPatientRelation); await db.SaveChangesAsync(); return(Ok(doctorPatientRelation)); }