Example #1
0
        public async Task <IHttpActionResult> PostTbl_DonNhapHang(Tbl_DonNhapHang tbl_DonNhapHang)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Tbl_DonNhapHang.Add(tbl_DonNhapHang);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (Tbl_DonNhapHangExists(tbl_DonNhapHang.DNH_ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = tbl_DonNhapHang.DNH_ID }, tbl_DonNhapHang));
        }
Example #2
0
        public async Task <IHttpActionResult> PutTbl_DonNhapHang(string id, Tbl_DonNhapHang tbl_DonNhapHang)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #3
0
        public async Task <IHttpActionResult> GetTbl_DonNhapHang(string id)
        {
            Tbl_DonNhapHang tbl_DonNhapHang = await db.Tbl_DonNhapHang.FindAsync(id);

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

            return(Ok(tbl_DonNhapHang));
        }
Example #4
0
        public async Task <IHttpActionResult> DeleteTbl_DonNhapHang(string id)
        {
            Tbl_DonNhapHang tbl_DonNhapHang = await db.Tbl_DonNhapHang.FindAsync(id);

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

            db.Tbl_DonNhapHang.Remove(tbl_DonNhapHang);
            await db.SaveChangesAsync();

            return(Ok(tbl_DonNhapHang));
        }