public async Task <IHttpActionResult> PostTbl_ChitietDonNhapHang(Tbl_ChitietDonNhapHang tbl_ChitietDonNhapHang)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Tbl_ChitietDonNhapHang.Add(tbl_ChitietDonNhapHang);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (Tbl_ChitietDonNhapHangExists(tbl_ChitietDonNhapHang.CTDNH_ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = tbl_ChitietDonNhapHang.CTDNH_ID }, tbl_ChitietDonNhapHang));
        }
        public async Task <IHttpActionResult> PutTbl_ChitietDonNhapHang(string id, Tbl_ChitietDonNhapHang tbl_ChitietDonNhapHang)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> GetTbl_ChitietDonNhapHang(string id)
        {
            Tbl_ChitietDonNhapHang tbl_ChitietDonNhapHang = await db.Tbl_ChitietDonNhapHang.FindAsync(id);

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

            return(Ok(tbl_ChitietDonNhapHang));
        }
        public async Task <IHttpActionResult> DeleteTbl_ChitietDonNhapHang(string id)
        {
            Tbl_ChitietDonNhapHang tbl_ChitietDonNhapHang = await db.Tbl_ChitietDonNhapHang.FindAsync(id);

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

            db.Tbl_ChitietDonNhapHang.Remove(tbl_ChitietDonNhapHang);
            await db.SaveChangesAsync();

            return(Ok(tbl_ChitietDonNhapHang));
        }