Пример #1
0
        public IHttpActionResult PutKhachHang(string id, KhachHang khachHang)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != khachHang.MaKhachHang)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!KhachHangExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public IHttpActionResult PutSach(string id, Sach sach)
        {
            db.Configuration.ProxyCreationEnabled = false;
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //if (id != sach.MaSach)
            //{
            //    return BadRequest();
            //}

            db.Entry(sach).State = EntityState.Modified;
            db.SaveChanges();
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SachExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }