public IHttpActionResult PostCT_DATHANG(CT_DATHANG cT_DATHANG) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CT_DATHANG.Add(cT_DATHANG); try { db.SaveChanges(); } catch (DbUpdateException) { if (CT_DATHANGExists(cT_DATHANG.madathang)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = cT_DATHANG.madathang }, cT_DATHANG)); }
public IHttpActionResult PutCT_DATHANG(string id, CT_DATHANG cT_DATHANG) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cT_DATHANG.madathang) { return(BadRequest()); } db.Entry(cT_DATHANG).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CT_DATHANGExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult XacNhanGioHang(int id) { DONDATHANG ddh = (DONDATHANG)Session["DatHang"]; if (id == 0) { ddh.TRANGTHAITHANHTOAN = false; } else { ddh.TRANGTHAITHANHTOAN = true; } List <GioHang> gh = LayGioHang(); data.DONDATHANGs.InsertOnSubmit(ddh); data.SubmitChanges(); foreach (var item in gh) { CT_DATHANG ctdh = new CT_DATHANG(); ctdh.MADDH = ddh.MADDH; ctdh.MASP = item.iMaSP; ctdh.SOLUONGDAT = item.iSoLuong; ctdh.DONGIA = (decimal)item.dDonGia; data.CT_DATHANGs.InsertOnSubmit(ctdh); } data.SubmitChanges(); Session["GioHang"] = null; Session["DatHang"] = null; return(View()); }
public IHttpActionResult GetCT_DATHANG(string id) { CT_DATHANG cT_DATHANG = db.CT_DATHANG.Find(id); if (cT_DATHANG == null) { return(NotFound()); } return(Ok(cT_DATHANG)); }
public IHttpActionResult DeleteCT_DATHANG(string id) { CT_DATHANG cT_DATHANG = db.CT_DATHANG.Find(id); if (cT_DATHANG == null) { return(NotFound()); } db.CT_DATHANG.Remove(cT_DATHANG); db.SaveChanges(); return(Ok(cT_DATHANG)); }