public async Task <IHttpActionResult> PostInfoHospital(InfoHospital infoHospital)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.InfoHospitals.Add(infoHospital);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (InfoHospitalExists(infoHospital.IDInfoHospital))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = infoHospital.IDInfoHospital }, infoHospital));
        }
        public async Task <IHttpActionResult> PutInfoHospital(int id, InfoHospital infoHospital)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != infoHospital.IDInfoHospital)
            {
                return(BadRequest());
            }

            db.Entry(infoHospital).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InfoHospitalExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> GetInfoHospital(int id)
        {
            InfoHospital infoHospital = await db.InfoHospitals.FindAsync(id);

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

            return(Ok(infoHospital));
        }
        public async Task <IHttpActionResult> DeleteInfoHospital(int id)
        {
            InfoHospital infoHospital = await db.InfoHospitals.FindAsync(id);

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

            db.InfoHospitals.Remove(infoHospital);
            await db.SaveChangesAsync();

            return(Ok(infoHospital));
        }