public IHttpActionResult PutDM_DonViTinh(int id, DM_DonViTinh dM_DonViTinh)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
        public IHttpActionResult GetDM_DonViTinh(int id)
        {
            DM_DonViTinh dM_DonViTinh = db.DM_DonViTinh.Find(id);
            if (dM_DonViTinh == null)
            {
                return NotFound();
            }

            return Ok(dM_DonViTinh);
        }
        public IHttpActionResult PostDM_DonViTinh(DM_DonViTinh dM_DonViTinh)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.DM_DonViTinh.Add(dM_DonViTinh);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = dM_DonViTinh.id }, dM_DonViTinh);
        }
        public IHttpActionResult DeleteDM_DonViTinh(int id)
        {
            DM_DonViTinh dM_DonViTinh = db.DM_DonViTinh.Find(id);
            if (dM_DonViTinh == null)
            {
                return NotFound();
            }

            db.DM_DonViTinh.Remove(dM_DonViTinh);
            db.SaveChanges();

            return Ok(dM_DonViTinh);
        }
Exemple #5
0
 public void Save(DM_DonViTinh data)
 {
     using (Karaoke2017Entities db = new Karaoke2017Entities())
     {
         //if (data.id > 0)
         //{
         //    var nhomHang = db.DM_DonViTinh.Find(data.id);
         //    nhomHang.ma = data.ma;
         //    nhomHang.ten = data.ten;
         //    nhomHang.ghichu = data.ghichu;
         //    db.SaveChanges();
         //}
         //else
         //{
         //    db.DM_DonViTinh.Add(data);
         //    db.SaveChanges();
         //}
     }
 }