public async Task <IHttpActionResult> PutDoctor(int id, Doctor doctor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != doctor.IDDoctor)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> ChangeAvatar(int id)
        {
            var acc = LoginHelper.GetAccount();

            if (acc.IDAccountBN != id)
            {
                return(NotFound());
            }

            var Account_BenhNhan = db.Account_BenhNhan.Find(id);

            if (Account_BenhNhan != null)
            {
                var save = UploadHelper.SaveImage();
                if (save.Key)
                {
                    db.Entry(Account_BenhNhan).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    return(Ok());
                }
                return(Content(HttpStatusCode.NotAcceptable, save.Key));
            }
            return(BadRequest());
        }
        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));
        }
Example #4
0
        public async Task <IHttpActionResult> PutPosition(int id, Position position)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != position.IDPosition)
            {
                return(BadRequest());
            }

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

            try
            {
                return(Ok(await db.SaveChangesAsync() > 0));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PositionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
        }
        public async Task <IHttpActionResult> PutHistoryKhamBenh(int id, HistoryKhamBenh historyKhamBenh)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != historyKhamBenh.IDHistory)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #6
0
        public async Task <IHttpActionResult> PutChuyenKhoa(int id, ChuyenKhoa chuyenKhoa)
        {
            if (id != chuyenKhoa.IDChuyenKhoa)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> PutCTToaThuoc(int id, CTToaThuoc cTToaThuoc)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cTToaThuoc.IDCT)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }