Ejemplo n.º 1
0
        public IHttpActionResult GetMH_YEU_CAU_HOI_GIA(int id)
        {
            MH_YEU_CAU_HOI_GIA mH_YEU_CAU_HOI_GIA = db.MH_YEU_CAU_HOI_GIA.Find(id);

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

            return(Ok(mH_YEU_CAU_HOI_GIA));
        }
        public IHttpActionResult PostMH_YEU_CAU_HOI_GIA(MH_YEU_CAU_HOI_GIA mH_YEU_CAU_HOI_GIA)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.MH_YEU_CAU_HOI_GIA.Add(mH_YEU_CAU_HOI_GIA);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = mH_YEU_CAU_HOI_GIA.ID }, mH_YEU_CAU_HOI_GIA));
        }
Ejemplo n.º 3
0
        public IHttpActionResult DeleteMH_YEU_CAU_HOI_GIA(int id)
        {
            MH_YEU_CAU_HOI_GIA mH_YEU_CAU_HOI_GIA = db.MH_YEU_CAU_HOI_GIA.Find(id);

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

            db.MH_YEU_CAU_HOI_GIA.Remove(mH_YEU_CAU_HOI_GIA);
            db.SaveChanges();

            return(Ok(mH_YEU_CAU_HOI_GIA));
        }
Ejemplo n.º 4
0
        public IHttpActionResult PutMH_YEU_CAU_HOI_GIA(int id, MH_YEU_CAU_HOI_GIA ychg)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            var query = db.MH_YEU_CAU_HOI_GIA.Where(x => x.ID == id).FirstOrDefault();

            if (query != null)
            {
                query.PUR_XU_LY = ychg.PUR_XU_LY;
            }

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

            return(Ok(ychg));
        }
        public IHttpActionResult PutMH_YEU_CAU_HOI_GIA(int id, MH_YEU_CAU_HOI_GIA mH_YEU_CAU_HOI_GIA)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            var xuly = db.MH_YEU_CAU_HOI_GIA.Where(x => x.ID == id).FirstOrDefault();

            if (xuly != null)
            {
                xuly.TRANG_THAI = mH_YEU_CAU_HOI_GIA.TRANG_THAI;
            }

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 6
0
        public IHttpActionResult PostMH_YEU_CAU_HOI_GIA(MH_YEU_CAU_HOI_GIA yeucau)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            MH_YEU_CAU_HOI_GIA YCHG = new MH_YEU_CAU_HOI_GIA();

            YCHG.MA_HANG        = yeucau.MA_HANG;
            YCHG.MA_CHUAN       = yeucau.MA_CHUAN;
            YCHG.MA_KHACH_ORDER = yeucau.MA_KHACH_ORDER;
            YCHG.THONG_SO       = yeucau.THONG_SO;
            YCHG.HANG           = yeucau.HANG;
            YCHG.SALES_YEU_CAU  = yeucau.SALES_YEU_CAU;
            YCHG.SO_LUONG       = yeucau.SO_LUONG;
            YCHG.NGAY_HOI_GIA   = DateTime.Today.Date;
            YCHG.GHI_CHU        = yeucau.GHI_CHU;
            YCHG.TRANG_THAI     = false;
            YCHG.TRUC_THUOC     = yeucau.TRUC_THUOC;
            db.MH_YEU_CAU_HOI_GIA.Add(YCHG);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = YCHG.ID }, YCHG));
        }