public IHttpActionResult PutCTDenGiaoThong(int id, CTDenGiaoThong cTDenGiaoThong)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult GetCTDenGiaoThong(int id)
        {
            CTDenGiaoThong cTDenGiaoThong = db.CTDenGiaoThong.Find(id);

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

            return(Ok(cTDenGiaoThong));
        }
        public IHttpActionResult PostCTDenGiaoThong(CTDenGiaoThong cTDenGiaoThong)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CTDenGiaoThong.Add(cTDenGiaoThong);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = cTDenGiaoThong.ma_ct_den }, cTDenGiaoThong));
        }
        public IHttpActionResult DeleteCTDenGiaoThong(int id)
        {
            CTDenGiaoThong cTDenGiaoThong = db.CTDenGiaoThong.Find(id);

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

            db.CTDenGiaoThong.Remove(cTDenGiaoThong);
            db.SaveChanges();

            return(Ok(cTDenGiaoThong));
        }
        public IHttpActionResult Postchotgiaothongdetail(ChotGiaoThongDetail chotGiaoThongDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            foreach (NgaDuong nga in chotGiaoThongDetail.ngaDuongs)
            {
                foreach (CTDenGiaoThong ct in nga.cTDens)
                {
                    CTDenGiaoThong temp = db.CTDenGiaoThong.Find(ct.ma_ct_den);
                    temp.vang            = ct.vang;
                    temp.xanh            = ct.xanh;
                    temp.do_             = ct.do_;
                    db.Entry(temp).State = EntityState.Modified;
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        if (db.CTDenGiaoThong.Count(e => e.ma_ct_den == temp.ma_ct_den) == 0)
                        {
                            return(NotFound());
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
            }
            var kq = GetChotGTDetail(chotGiaoThongDetail.ngaDuongs[0].ma_chot_GT);

            return(kq);
        }