예제 #1
0
        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));
        }
예제 #2
0
        public async Task <IHttpActionResult> GetDoctorPatientRelation(int id)
        {
            DoctorPatientRelation doctorPatientRelation = await db.DoctorPatientRelations.FindAsync(id);

            if (doctorPatientRelation == null)
            {
                return(NotFound());
            }

            return(Ok(doctorPatientRelation));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }